Open MaherAccor opened 5 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.
can you please shows me full exemple how can do that.
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', }, ], ],
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)
also i would like to know if i should do somthing in package.json?
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', },
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" } }
i have a error > There are no tests with such /^(.+?) | / key pattern?
if you have a full example with playwright in github it will be very easy for me to know how do that .
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
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
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';
/**
/**
See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests-examples',
testMatch: '*/.ts',
timeout:101000,
expect:{
timeout:3000
},
/ 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 ? 2 : 0,
retries:1,
/ 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',
/ 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: 'http://127.0.0.1:3000',
/ Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer / trace: 'on-first-retry', },
/ Configure projects for major browsers / projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'] }, },
{ name: 'firefox', use: { ...devices['Desktop Firefox'] }, },
{ name: 'webkit', use: { ...devices['Desktop Safari'] }, },
/ Test against mobile viewports. / // { // name: 'Mobile Chrome', // use: { ...devices['Pixel 5'] }, // }, // { // name: 'Mobile Safari', // use: { ...devices['iPhone 12'] }, // },
/ Test against branded browsers. / // { // name: 'Microsoft Edge', // use: { ...devices['Desktop Edge'], channel: 'msedge' }, // }, // { // name: 'Google Chrome', // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, // }, ],
/ Run your local dev server before starting the tests / // webServer: { // command: 'npm run start', // url: 'http://127.0.0.1:3000', // reuseExistingServer: !process.env.CI, // }, });
if you can share me your conf in the two package.json and playwright.config.ts
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,
}
}
],
});
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" } }
Does it work now?
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 ?