@@ -15,8 +15,6 @@ npm i -D playwright-xray
15
15
16
16
Add reporter to your ` playwright.config.ts ` configuration file
17
17
18
-
19
-
20
18
### Cloud version
21
19
22
20
Authenticate with ` client_id ` and ` client_secret ` key.
@@ -26,20 +24,25 @@ Authenticate with `client_id` and `client_secret` key.
26
24
import { PlaywrightTestConfig } from ' @playwright/test' ;
27
25
28
26
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
+ };
43
46
```
44
47
45
48
### Server version
@@ -51,25 +54,30 @@ Authenticate with `token` key.
51
54
import { PlaywrightTestConfig } from ' @playwright/test' ;
52
55
53
56
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
+ };
67
75
```
68
76
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 + ` | ` :
70
78
71
79
``` typescript
72
- // Xray test case ID inside square brackets
80
+ // Xray test case ID + |
73
81
test (' J79 | basic test' , async ({ page }) => {
74
82
await page .goto (' https://playwright.dev/' );
75
83
const title = page .locator (' .navbar__inner .navbar__title' );
@@ -78,72 +86,87 @@ test('J79 | basic test', async ({ page }) => {
78
86
```
79
87
80
88
### Optional config
89
+
81
90
Is it possible to add some optional values to the Test Execution ticket.
91
+
82
92
``` typescript
83
93
// playwright.config.ts
84
94
import { PlaywrightTestConfig } from ' @playwright/test' ;
85
95
86
96
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
+ };
110
125
```
111
126
112
127
### Proxy
128
+
113
129
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
+
114
131
``` typescript
115
132
// playwright.config.ts
116
133
import { PlaywrightTestConfig } from ' @playwright/test' ;
117
134
118
135
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
+ };
146
168
```
169
+
147
170
> If your proxy server doesn't need authentication, just omit the ` auth ` part.
148
171
>
149
172
> 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
154
177
155
178
``` sh
156
179
-------------------------------------
157
-
180
+
158
181
⏺ Starting the run with 6 tests
159
-
182
+
160
183
✅ Chrome | XRAYISSUE-2 | another test
161
184
✅ Chrome | XRAYISSUE-1 | basic test
162
185
✅ Firefox | XRAYISSUE-1 | basic test
163
186
⛔ Chrome | XRAYISSUE-3 | another test
164
187
⛔ Firefox | XRAYISSUE-2 | another test
165
188
⛔ Firefox | XRAYISSUE-3 | another test
166
-
189
+
167
190
-------------------------------------
168
-
191
+
169
192
😀 Successfully sending test results to Jira
170
-
193
+
171
194
⏺ Description: Tests executed with playwright-xray plugin
172
195
⏺ Test environments: dev,test
173
196
⏺ Version: 3.5.2
174
197
⏺ Revision: 12345
175
198
⏺ Browsers: Chrome, Firefox
176
199
⏺ Test plan: XRAYISSUE-123
177
200
⏺ Test execution: XRAYISSUE-324
178
- ⏺ Test Duration: 25s
201
+ ⏺ Test Duration: 25s
179
202
⏺ Tests ran: 6
180
203
⏺ Tests passed: 3
181
204
⏺ Tests failed: 3
182
-
205
+
183
206
-------------------------------------
184
-
207
+
185
208
⏺ Test cycle XRAYISSUE-324 has been updated
186
209
👇 Check out the test result
187
210
🔗 https://jira.com/XRAYISSUE-324
188
-
211
+
189
212
-------------------------------------
190
213
```
191
214
192
215
And you'll see the result in the Xray:
193
216
194
217
![ alt text] ( ./assets/xray-result.png )
195
218
196
-
197
219
## Multiple Test Plans
198
220
199
221
If you need to send report for more than one test plan, you need to create a config file for each test plan.
200
222
Create a folder (e.g. configs) in your project and for each test plan, create a new playwright config file in this folder.
201
223
202
- ``` ts
224
+ ``` ts
203
225
// configs/TCK-87.config.ts
204
226
205
- import { PlaywrightTestConfig } from " @playwright/test" ;
206
- import base from " ../playwright.config" ;
227
+ import { PlaywrightTestConfig } from ' @playwright/test' ;
228
+ import base from ' ../playwright.config' ;
207
229
208
230
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: {
220
242
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
+ },
226
248
projectKey: ' TCK' ,
227
- testPlan: ' TCK-87'
228
- },
229
- ],
230
- ],
249
+ testPlan: ' TCK-87' ,
250
+ },
251
+ ],
252
+ ],
231
253
};
232
254
export default config ;
233
255
```
256
+
234
257
Now you can choose which config file you want to use executing the tests, using the command below:
258
+
235
259
```
236
260
npx playwright test --config=configs/TCK-87.config.ts
237
261
```
262
+
238
263
If no config file is chosen, the default config file "playwright.config.ts" will be used.
239
264
240
265
## Notes
241
266
242
267
- 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.
244
269
245
270
## License
246
271
0 commit comments