GithubHelp home page GithubHelp logo

playwright-zephyr's Introduction

Zephyr reporter for Playwright

Publish Playwright test run on Zephyr

Install

npm i -D playwright-zephyr

Usage

Add Server reporter to your playwright.config.ts configuration file

// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
  reporter: [['playwright-zephyr', { 
    host: 'https://jira.your-company-domain.com/',
    authorizationToken: 'SVSdrtwgDSA312342--',
    projectKey: 'JARV'
  }]],
}

If you want to use Cloud reporter, you need to specify cloud option:

// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
  reporter: [
    ['playwright-zephyr/lib/src/cloud', {
      projectKey: 'JARV', // <-- Replace with your project key
      authorizationToken: process.env.ZEPHYR_AUTH_TOKEN, // <-- Replace with your authorization token
    }],
  ],
}

If your test cycle requires custom fields, you can specify them in testCycle option:

// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
    reporter: [
    ['playwright-zephyr/lib/src/cloud', {
      projectKey: 'JARV', // <-- Replace with your project key
      authorizationToken: process.env.ZEPHYR_AUTH_TOKEN, // <-- Replace with your authorization token
      testCycle: {
          name: `Automated Playwright Run - ${new Date().toISOString()}`,
          customFields: {
            Browser: 'Google Chrome',
            Device: 'MacOS',
          },
        },
    }],
  ],
}

Read how to get Zephyr authorization token here.

Also, your playwright tests should include unique ID inside square brackets [J79] of your Zephyr test case:

//      ↓  Zephyr test case ID inside square brackets
test('[J79] basic test', async ({ page }) => {
  await page.goto('https://playwright.dev/');
  const title = page.locator('.navbar__inner .navbar__title');
  await expect(title).toHaveText('Playwright');
});

Then run your tests with npx playwright test command and you'll see the result in console:

✅ Test cycle JARV-C2901 has been created
👇 Check out the test result
🔗 https://jira.your-company-domain.com/secure/Tests.jspa#/testPlayer/JARV-C2901

And you'll see the result in the Zephyr:

alt text

License

playwright-zephyr is MIT licensed.

Author

Yevhen Laichenkov [email protected]

playwright-zephyr's People

Contributors

dependabot[bot] avatar elaichenkov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

playwright-zephyr's Issues

Support to add multiple test tags to single playwright test case.

test('Verify home page contents after successful login [T2662, T1234, T4321]',{tag:"@e2eFlow"}, async ({ page }) => { });
test('Verify home page contents after successful login [T2662][T1234][T4321]',{tag:"@e2eFlow"}, async ({ page }) => { });

Support to add multiple test tags to single test cases in any above given example formats.
It will be helpful to tag mutiple test cases from zephyr to one e2e scenario from playwright.

Unsuccessful Connection

When trying to use the library after corresponding configuration with authentication token, I get the following error: "Data: 'Basic authentication with passwords is deprecated." This is returning me 401 code.

Also, after checking API request, I see the following in headers:

headers: {
    Accept: 'application/json, text/plain, */*',
    'Content-Type': 'application/json',
    Authorization: 'Basic 3cLJWXI9oURy4JjkrzgfDEXX',
    'User-Agent': 'axios/0.24.0',
    'Content-Length': 934
  },

Add option to place test results into test cycle folder

In an effort to keep the automation runs separate from any manual runs, it would be nice to have the ability to specify where the test results go. I propose, if possible, being able to point it at a pre-existing test cycle folder setup prior to run.

Reporting comments for error and stack trace variables are appearing uninteligable in Zephyr Scale cloud

I had a simple set of Typescript Playwright API tests set up and reporting just fine (error and stack trace messages reflected playwright's test results ) with the provided zephyr cloud reporter settings,

I progressed my test design by creating helper object classes and changing the .spect.ts import of test from @playwright/test to my fixture.ts which extends test via
import { test as base } from '@playwright/test';
and substantiate the class making use of it's constructor

export const test = base.extend<{ 
  importedHelperClass: ImportedHelperClass;
}>({
    importedHelperClass:async ({request}, use) => {
        await use(new ImportedHelperClass(request));      
    }
});

Since then the error and stack trace messages recorded in Zephyr Scale are far from human readable:

❌ Error Message:
�[2mexpect(�[22m�[31mreceived�[39m�[2m).�[22mtoBe�[2m(�[22m�[32mexpected�[39m�[2m) // Object.is equality�[22m

Expected: �[32m400�[39m
Received: �[31m200�[39m

🧱 Stack Trace:
Error: �[2mexpect(�[22m�[31mreceived�[39m�[2m).�[22mtoBe�[2m(�[22m�[32mexpected�[39m�[2m) // Object.is equality�[22m

Expected: �[32m400�[39m
Received: �[31m200�[39m

Is there something to further configure in the reporter? or is this an issue with the repo not handling playwright test being extended?

Problem with Bearer token

It is not possible to login using bearer token.

The token type is always BASIC
https://github.com/elaichenkov/playwright-zephyr/blob/main/src/zephyr.service.ts#L40

    this.password = options.password!;
    let tokenType = 'Basic'
    if (this.authorizationToken ){
      tokenType = 'Bearer     //  <------ Bearer if authorizationToken
   }
    this.basicAuthToken = Buffer.from(`${this.user}:${this.password}`).toString('base64');
    this.authorizationToken = options.authorizationToken ?? this.basicAuthToken;
    this.projectKey = options.projectKey;

    this.axios = axios.create({
      baseURL: this.url,
      headers: {
        'Content-Type': 'application/json',
        Authorization: `${tokenType} ${this.authorizationToken}`,   <---------------
      },

[BUG] - undefined (reading 'registrations')

Hi, I am facing the below issue.

Configuration:

  reporter: [
    [
      "playwright-zephyr",
      {
        host: "https://project.atlassian.net/",
        authorizationToken:"token",
        projectKey: "projectKEY",
      },
    ],
  ],

Error message:
Error in reporter TypeError: Cannot read properties of undefined (reading 'registrations')

Playwright version - "@playwright/test": "^1.31.2",

[Feature] Python version

Hi,
I like the idea, great job, but it does'n work for playwright for python
Is it possible to create a pytest version?
Cheers

Proxy issue - add an option to inject a custom proxy for the service

This is an excellent plugin. Nice work!
I'm using it today, turned out running behind the company proxy is problematic(self-signed certificate, HTTP proxy, calling HTTPS api).
I have to manually add a proxy config in zephyr.service.js

const httpsAgent = new https.Agent ({
        requestcert: true,
        rejectUnauthorized: false,
        baseURL: this.url
        proxy: {
          host: 'localhost',
          port: 3128,
        }});
this.axios = axios_1.default.create( {
        baseURL: this.url,
        proxy: false, 
        httpsAgent: httpsAgent,
        headers: {
        'Content-Type': 'application/json',
        Authorization: `Basic ${this.authorizationToken}`,
        }));

Maybe add an option to inject a custom proxy for the service?

Not able to use the feature

I want to upload my run results to Zephyr but I am getting the below error
Basic authentication with passwords is deprecated.

Here is the reporter configs
['playwright-zephyr', {
host: 'https://------.atlassian.net/jira',
user: '[email protected]',
password: 'ABCDE@123',
authorizationToken:'563556353563hdsdgh',
projectKey: 'KEY'
}]

Please help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.