inluxc / playwright-xray

XRAY reporter for Playwright
MIT License
26 stars 11 forks source link

Attach plan test with test execution #80

Open MaherAccor opened 5 days ago

MaherAccor commented 5 days ago

Hello i would like to know how can added test execution to testplan in the end of executions? It's possible to add this from the configuration file ?

Niklas-Back commented 4 days ago

Yes, if you want the reporter to automatically update Xray with the test execution, you specify the test plan in the playwright config file in the reporter section.

MaherAccor commented 4 days ago

can you please shows me full exemple how can do that.

Niklas-Back commented 4 days ago

Of course. In the example below test plan TCK-87 is used reporter: [ [ 'playwright-xray', { jira: { url: 'https://your-jira-url', type: 'server', apiVersion: '1.0', }, server: { token: 'YOUR_SERVER_TOKEN', }, projectKey: 'TCK', testPlan: 'TCK-87', }, ], ],

MaherAccor commented 4 days ago

i'am using jira cloud et not server in variable jira / url i put which url :
1.https://xray.cloud.getxray.app/api/v2 (url xray)

  1. https://-it.atlassian.net/browse (url project)
MaherAccor commented 4 days ago

also i would like to know if i should do somthing in package.json?

Niklas-Back commented 4 days ago

You dont have to specify the xray url because it will default to https://xray.cloud.getxray.app/ The setting is used if it differs from default. E.g. this is my cloud configuration { jira: { url: 'https://myCompany.atlassian.net/', type: 'cloud', apiVersion: '1.0', }, cloud: { client_id: 'xxxxxxxxxxx', client_secret: 'yyyyyyyyy', },

MaherAccor commented 4 days ago

Ok thanks , i have a last question , i want to know if i do somthing in the file package.json .this my file { "name": "xrayplay", "version": "1.0.0", "main": "index.js", "scripts": { "test": "playwright test", "posttest": "npm test" }, "keywords": [], "author": "", "license": "ISC", "description": "", "devDependencies": { "@playwright/test": "^1.48.2", "@types/node": "^22.9.0", "playwright-xray": "^0.6.5" } }

MaherAccor commented 4 days ago

i have a error > There are no tests with such /^(.+?) | / key pattern?

MaherAccor commented 4 days ago

if you have a full example with playwright in github it will be very easy for me to know how do that .

Niklas-Back commented 4 days ago

Hi, if your test cases looks like this:

issueID | Test Case Name

Then post your file with test cases so I can have a look. Also how are you running the tests (Linux, Windows, Mac, Jenkins, Locally, GA etc)

Unfortunately we don't have our code in GitHub so the only example i can give is this https://github.com/inluxc/playwright-xray/blob/main/tests/simple.test.ts But it looks like you got the reporter correctly configured otherwise you wouldn't see that error message. Also post your playwright config file

Niklas-Back commented 3 days ago

If you are interested you could try my beta that imports testcases from playwright, creates Xray testcases and renames the testcases in playwright to issueID | Test Case Name

MaherAccor commented 3 days ago

Thank you for your response this is my config :
package.json : { "name": "xrayplay", "version": "1.0.0", "main": "index.js", "scripts":{}, "keywords": [], "author": "", "license": "ISC", "description": "", "devDependencies": { "@playwright/test": "^1.48.2", "@types/node": "^22.9.0", "playwright-xray": "^0.6.5", "typescript": "5.6.3" } } ANd this is the config in playwrights.configs.ts :
import { defineConfig, devices } from '@playwright/test';

/**

/**

MaherAccor commented 3 days ago

if you can share me your conf in the two package.json and playwright.config.ts

Niklas-Back commented 3 days ago

Hi,

This is my playwright.config.ts

import { defineConfig, devices } from '@playwright/test';

export default defineConfig({ testDir: './tests', / Run tests in files in parallel / fullyParallel: true, / Fail the build on CI if you accidentally left test.only in the source code. / forbidOnly: !!process.env.CI, / Retry on CI only / retries: process.env.CI ? 1 : 0, / Opt out of parallel tests on CI. / workers: process.env.CI ? 1 : undefined, / Reporter to use. See https://playwright.dev/docs/test-reporters / reporter: [['html'], [ 'playwright-xray', { jira: { url: 'https://myCompany.atlassian.net/', type: 'cloud', apiVersion: '1.0', }, cloud: { client_id: 'xxxxxxx', client_secret: 'yyyyyyyyyyy', }, projectKey: 'ABC', testPlan: 'ABC-10237', testEnvironments: ['Desktop Chrome'], debug: true, uploadScreenShot: true, uploadTrace: false, stepCategories: ['test.step'] }, ] ],

/ Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. / use: { / Base URL to use in actions like await page.goto('/'). / baseURL: process.env.TEST_ENVIRONMENT ? process.env.TEST_ENVIRONMENT : 'https://www.myCompany.abc',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'retain-on-failure',
video: 'off',
screenshot: 'only-on-failure',
actionTimeout: 10 * 1000,
navigationTimeout: 30 * 1000,
testIdAttribute: 'data-test'

},

timeout: 5 60 1000,

/ Configure projects for major browsers / projects: [ { name: 'Desktop Chrome', use: { ...devices['Desktop Chrome'], channel: 'chrome', isMobile: false },

},

{
  name: 'Mobile Chrome',
  use: {
    ...devices['Samsung Galaxy S20'],
    channel: 'chrome',
    viewport: { width: 360, height: 667 },
    isMobile: true,
  }
}

],

});

Niklas-Back commented 2 days ago

Your package.json is fine. This is mine

{ "name": "skovde", "version": "1.0.0", "description": "", "main": "index.js", "scripts": {}, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "@playwright/test": "^1.45.2", "@types/node": "^20.12.7" }, "dependencies": { "playwright-xray": "^0.6.5" } }

Niklas-Back commented 1 day ago

Does it work now?