Skip to content

Commit 77c07b4

Browse files
coolswoodDaniil Sugonyaev
and
Daniil Sugonyaev
authored
Fixed regular expression, formatting and description (inluxc#53)
* testExecutionKey * update * fix * make testExecution optional * fix regexp * text fix * fix --------- Co-authored-by: Daniil Sugonyaev <daniil.sugonyaev@yolo.com>
1 parent c2233f9 commit 77c07b4

File tree

4 files changed

+175
-145
lines changed

4 files changed

+175
-145
lines changed

README.md

+140-115
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ npm i -D playwright-xray
1515

1616
Add reporter to your `playwright.config.ts` configuration file
1717

18-
19-
2018
### Cloud version
2119

2220
Authenticate with `client_id` and `client_secret` key.
@@ -26,20 +24,25 @@ Authenticate with `client_id` and `client_secret` key.
2624
import { PlaywrightTestConfig } from '@playwright/test';
2725

2826
const config: PlaywrightTestConfig = {
29-
reporter: [['playwright-xray', {
30-
jira: {
31-
url: 'https://your-jira-url',
32-
type: 'cloud'
33-
},
34-
cloud: {
35-
client_id: '',
36-
client_secret: '',
37-
},
38-
projectKey: 'JIRA_CODE',
39-
testPlan: 'JIRA_CODEXXXXX',
40-
debug: false
41-
}]],
42-
}
27+
reporter: [
28+
[
29+
'playwright-xray',
30+
{
31+
jira: {
32+
url: 'https://your-jira-url',
33+
type: 'cloud',
34+
},
35+
cloud: {
36+
client_id: '',
37+
client_secret: '',
38+
},
39+
projectKey: 'JIRA_CODE',
40+
testPlan: 'JIRA_CODEXXXXX',
41+
debug: false,
42+
},
43+
],
44+
],
45+
};
4346
```
4447

4548
### Server version
@@ -51,25 +54,30 @@ Authenticate with `token` key.
5154
import { PlaywrightTestConfig } from '@playwright/test';
5255

5356
const config: PlaywrightTestConfig = {
54-
reporter: [['playwright-xray', {
55-
jira: {
56-
url: 'https://your-jira-url',
57-
type: 'server'
58-
},
59-
server: {
60-
token: 'YOUR_SERVER_TOKEN'
61-
},
62-
projectKey: 'JIRA_CODE',
63-
testPlan: 'JIRA_CODEXXXXX',
64-
debug: false
65-
}]],
66-
}
57+
reporter: [
58+
[
59+
'playwright-xray',
60+
{
61+
jira: {
62+
url: 'https://your-jira-url',
63+
type: 'server',
64+
},
65+
server: {
66+
token: 'YOUR_SERVER_TOKEN',
67+
},
68+
projectKey: 'JIRA_CODE',
69+
testPlan: 'JIRA_CODEXXXXX',
70+
debug: false,
71+
},
72+
],
73+
],
74+
};
6775
```
6876

69-
Also, your playwright tests should include unique ID inside square brackets `[J79]` of your Xray test case:
77+
Also, your playwright tests should include unique ID `J79` of your Xray test case + `|`:
7078

7179
```typescript
72-
// Xray test case ID inside square brackets
80+
// Xray test case ID + |
7381
test('J79 | basic test', async ({ page }) => {
7482
await page.goto('https://playwright.dev/');
7583
const title = page.locator('.navbar__inner .navbar__title');
@@ -78,72 +86,87 @@ test('J79 | basic test', async ({ page }) => {
7886
```
7987

8088
### Optional config
89+
8190
Is it possible to add some optional values to the Test Execution ticket.
91+
8292
```typescript
8393
// playwright.config.ts
8494
import { PlaywrightTestConfig } from '@playwright/test';
8595

8696
const config: PlaywrightTestConfig = {
87-
reporter: [['playwright-xray', {
88-
jira: {
89-
url: 'https://your-jira-url',
90-
type: 'server'
91-
},
92-
cloud: {
93-
client_id: '',
94-
client_secret: '',
95-
},
96-
server: {
97-
token: ''
98-
},
99-
projectKey: 'JIRA_CODE',
100-
testPlan: 'JIRA_CODE-XXX',
101-
debug: false,
102-
// Optional
103-
testExecution: 'JIRA_CODE-YYY',
104-
version: 'v1.0',
105-
revision: '12345',
106-
description: 'This test was executed automatically',
107-
testEnvironments: ['dev', 'test'],
108-
}]],
109-
}
97+
reporter: [
98+
[
99+
'playwright-xray',
100+
{
101+
jira: {
102+
url: 'https://your-jira-url',
103+
type: 'server',
104+
},
105+
cloud: {
106+
client_id: '',
107+
client_secret: '',
108+
},
109+
server: {
110+
token: '',
111+
},
112+
projectKey: 'JIRA_CODE',
113+
testPlan: 'JIRA_CODE-XXX',
114+
debug: false,
115+
// Optional
116+
testExecution: 'JIRA_CODE-YYY',
117+
version: 'v1.0',
118+
revision: '12345',
119+
description: 'This test was executed automatically',
120+
testEnvironments: ['dev', 'test'],
121+
},
122+
],
123+
],
124+
};
110125
```
111126

112127
### Proxy
128+
113129
If you use a proxy to access Jira, you need to configure the proxy. This proxy information will be used by Axios to send the results to Jira.
130+
114131
```typescript
115132
// playwright.config.ts
116133
import { PlaywrightTestConfig } from '@playwright/test';
117134

118135
const config: PlaywrightTestConfig = {
119-
reporter: [['playwright-xray', {
120-
jira: {
121-
url: 'https://your-jira-url',
122-
type: 'server'
123-
},
124-
cloud: {
125-
client_id: '',
126-
client_secret: '',
127-
},
128-
server: {
129-
token: ''
130-
},
131-
projectKey: 'JIRA_CODE',
132-
testPlan: 'JIRA_CODE-XXX',
133-
debug: false,
134-
// Optional
135-
proxy: {
136-
protocol: 'http',
137-
host: '0.0.0.0',
138-
port: 80,
139-
auth: {
140-
username: 'USER',
141-
password: 'p@$$w0Rd'
142-
}
143-
}
144-
}]],
145-
}
136+
reporter: [
137+
[
138+
'playwright-xray',
139+
{
140+
jira: {
141+
url: 'https://your-jira-url',
142+
type: 'server',
143+
},
144+
cloud: {
145+
client_id: '',
146+
client_secret: '',
147+
},
148+
server: {
149+
token: '',
150+
},
151+
projectKey: 'JIRA_CODE',
152+
testPlan: 'JIRA_CODE-XXX',
153+
debug: false,
154+
// Optional
155+
proxy: {
156+
protocol: 'http',
157+
host: '0.0.0.0',
158+
port: 80,
159+
auth: {
160+
username: 'USER',
161+
password: 'p@$$w0Rd',
162+
},
163+
},
164+
},
165+
],
166+
],
167+
};
146168
```
169+
147170
> If your proxy server doesn't need authentication, just omit the `auth` part.
148171
>
149172
> If no proxy is configured, Axios is forced to doesn't use proxy.
@@ -154,93 +177,95 @@ Then run your tests with `npx playwright test` command and you'll see the result
154177

155178
```sh
156179
-------------------------------------
157-
180+
158181
⏺ Starting the run with 6 tests
159-
182+
160183
✅ Chrome | XRAYISSUE-2 | another test
161184
✅ Chrome | XRAYISSUE-1 | basic test
162185
✅ Firefox | XRAYISSUE-1 | basic test
163186
⛔ Chrome | XRAYISSUE-3 | another test
164187
⛔ Firefox | XRAYISSUE-2 | another test
165188
⛔ Firefox | XRAYISSUE-3 | another test
166-
189+
167190
-------------------------------------
168-
191+
169192
😀 Successfully sending test results to Jira
170-
193+
171194
⏺ Description: Tests executed with playwright-xray plugin
172195
⏺ Test environments: dev,test
173196
⏺ Version: 3.5.2
174197
⏺ Revision: 12345
175198
⏺ Browsers: Chrome, Firefox
176199
⏺ Test plan: XRAYISSUE-123
177200
⏺ Test execution: XRAYISSUE-324
178-
⏺ Test Duration: 25s
201+
⏺ Test Duration: 25s
179202
⏺ Tests ran: 6
180203
⏺ Tests passed: 3
181204
⏺ Tests failed: 3
182-
205+
183206
-------------------------------------
184-
207+
185208
⏺ Test cycle XRAYISSUE-324 has been updated
186209
👇 Check out the test result
187210
🔗 https://jira.com/XRAYISSUE-324
188-
211+
189212
-------------------------------------
190213
```
191214

192215
And you'll see the result in the Xray:
193216

194217
![alt text](./assets/xray-result.png)
195218

196-
197219
## Multiple Test Plans
198220

199221
If you need to send report for more than one test plan, you need to create a config file for each test plan.
200222
Create a folder (e.g. configs) in your project and for each test plan, create a new playwright config file in this folder.
201223

202-
``` ts
224+
```ts
203225
// configs/TCK-87.config.ts
204226

205-
import { PlaywrightTestConfig } from "@playwright/test";
206-
import base from "../playwright.config";
227+
import { PlaywrightTestConfig } from '@playwright/test';
228+
import base from '../playwright.config';
207229

208230
const config: PlaywrightTestConfig = {
209-
...base,
210-
testDir: "../tests",
211-
use: {
212-
...base.use,
213-
headless: true,
214-
},
215-
reporter: [
216-
[
217-
"playwright-xray",
218-
{
219-
jira: {
231+
...base,
232+
testDir: '../tests',
233+
use: {
234+
...base.use,
235+
headless: true,
236+
},
237+
reporter: [
238+
[
239+
'playwright-xray',
240+
{
241+
jira: {
220242
url: 'https://your-jira-url',
221-
type: 'server'
222-
},
223-
server: {
224-
token: 'YOUR_SERVER_TOKEN',
225-
},
243+
type: 'server',
244+
},
245+
server: {
246+
token: 'YOUR_SERVER_TOKEN',
247+
},
226248
projectKey: 'TCK',
227-
testPlan: 'TCK-87'
228-
},
229-
],
230-
],
249+
testPlan: 'TCK-87',
250+
},
251+
],
252+
],
231253
};
232254
export default config;
233255
```
256+
234257
Now you can choose which config file you want to use executing the tests, using the command below:
258+
235259
```
236260
npx playwright test --config=configs/TCK-87.config.ts
237261
```
262+
238263
If no config file is chosen, the default config file "playwright.config.ts" will be used.
239264

240265
## Notes
241266

242267
- To have the steps imported you have to create then in the test issue itself.
243-
The steps will be imported by order of execution and inserted into the test.
268+
The steps will be imported by order of execution and inserted into the test.
244269

245270
## License
246271

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)