@qanalyzer/forge-playwright 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +86 -0
- package/dist/__fixtures__/saucedemo-13.json +126 -0
- package/dist/enrich-screenshots.d.ts +13 -0
- package/dist/enrich-screenshots.js +85 -0
- package/dist/helpers.d.ts +31 -0
- package/dist/helpers.js +108 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +18 -0
- package/dist/metadata-from-result.d.ts +16 -0
- package/dist/metadata-from-result.js +53 -0
- package/dist/metadata-manager.d.ts +15 -0
- package/dist/metadata-manager.js +21 -0
- package/dist/report-builder.d.ts +25 -0
- package/dist/report-builder.js +84 -0
- package/dist/reporter.d.ts +26 -0
- package/dist/reporter.js +130 -0
- package/dist/step-extractor.d.ts +13 -0
- package/dist/step-extractor.js +31 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright © 2026 JSoft
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# @qanalyzer/forge-playwright
|
|
2
|
+
|
|
3
|
+
Playwright reporter for **QAnalyzer** (Jira Forge quality hub).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -D @qanalyzer/forge-playwright @qanalyzer/forge-commons @playwright/test
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer: `@playwright/test` ≥1.40.
|
|
12
|
+
|
|
13
|
+
## Configure
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
// playwright.config.js
|
|
17
|
+
const { defineConfig } = require('@playwright/test');
|
|
18
|
+
|
|
19
|
+
module.exports = defineConfig({
|
|
20
|
+
testDir: './test',
|
|
21
|
+
reporter: [
|
|
22
|
+
['list'],
|
|
23
|
+
[
|
|
24
|
+
'@qanalyzer/forge-playwright',
|
|
25
|
+
{
|
|
26
|
+
// Defaults to mode=off (no credentials required)
|
|
27
|
+
// mode: 'ingest' | 'file' | 'off',
|
|
28
|
+
// projectKey: 'DEMO',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
],
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Modes
|
|
36
|
+
|
|
37
|
+
| Mode | Behavior |
|
|
38
|
+
| ---- | -------- |
|
|
39
|
+
| `off` (default) | No network / file write |
|
|
40
|
+
| `file` | Writes the ingest payload (default `./qanalyzer-results.json`) |
|
|
41
|
+
| `ingest` | POSTs the payload with `format: jest-json` |
|
|
42
|
+
|
|
43
|
+
Env (same as CLI): `QANALYZER_MODE`, `QANALYZER_PROJECT_KEY`, `QANALYZER_INGEST_URL`, `QANALYZER_INGEST_TOKEN`, `QANALYZER_LAUNCH_NAME`.
|
|
44
|
+
|
|
45
|
+
## Helpers
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
const { test } = require('@playwright/test');
|
|
49
|
+
const { qa } = require('@qanalyzer/forge-playwright');
|
|
50
|
+
|
|
51
|
+
test('AUTH-101 login', async ({ page }) => {
|
|
52
|
+
qa.suite('Auth');
|
|
53
|
+
qa.fields({ layer: 'e2e' });
|
|
54
|
+
|
|
55
|
+
// Steps: native Playwright API only — no qa.step()
|
|
56
|
+
await test.step('open login', async () => {
|
|
57
|
+
await page.goto('/login');
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Prefer **Jira issue keys in test titles**. Native `test.step()` hierarchy lands on `assertionResults[].meta.qa.steps`.
|
|
63
|
+
|
|
64
|
+
`qa.attach({ contentType })` is metadata-only for now (binary upload deferred).
|
|
65
|
+
|
|
66
|
+
## Dual path
|
|
67
|
+
|
|
68
|
+
**Path A — Playwright JSON + CLI:**
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npx playwright test --reporter=json --output=qanalyzer-playwright.json
|
|
72
|
+
# Convert / upload with CLI when using raw Playwright JSON, or prefer Path B file mode:
|
|
73
|
+
npx @qanalyzer/forge-api-client --project DEMO --report qanalyzer-results.json
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Path B — @qanalyzer/forge-playwright reporter** (`mode=ingest` or `mode=file`):
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
QANALYZER_MODE=ingest \
|
|
80
|
+
QANALYZER_PROJECT_KEY=DEMO \
|
|
81
|
+
QANALYZER_INGEST_URL=... \
|
|
82
|
+
QANALYZER_INGEST_TOKEN=... \
|
|
83
|
+
npx playwright test
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`mode=file` writes an **ingest payload** (jest-json shape A) ready for Forge. Path A raw Playwright JSON is a separate dual-path option for teams that already emit Playwright's JSON reporter.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
{
|
|
2
|
+
"suite": "saucedemo-reference-playwright",
|
|
3
|
+
"source": "saucedemo e-commerce suite (login/inventory/cart/checkout) — titles use FR43 AUTH-* keys",
|
|
4
|
+
"specs": [
|
|
5
|
+
{
|
|
6
|
+
"name": "test/login.spec.js",
|
|
7
|
+
"assertions": [
|
|
8
|
+
{
|
|
9
|
+
"ancestorTitles": ["Login Scenarios"],
|
|
10
|
+
"title": "AUTH-101 User can login with valid credentials",
|
|
11
|
+
"status": "passed",
|
|
12
|
+
"duration": 1200,
|
|
13
|
+
"steps": [
|
|
14
|
+
"Fill in username",
|
|
15
|
+
"Fill in password",
|
|
16
|
+
"Submit login form",
|
|
17
|
+
"Verify successful login"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"ancestorTitles": ["Login Scenarios"],
|
|
22
|
+
"title": "AUTH-102 User cannot login with invalid password",
|
|
23
|
+
"status": "passed",
|
|
24
|
+
"duration": 800,
|
|
25
|
+
"steps": [
|
|
26
|
+
"Attempt login with invalid credentials",
|
|
27
|
+
"Verify error message is shown"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"ancestorTitles": ["Login Scenarios"],
|
|
32
|
+
"title": "AUTH-103 Locked user cannot login",
|
|
33
|
+
"status": "passed",
|
|
34
|
+
"duration": 700,
|
|
35
|
+
"steps": ["Attempt login with locked user", "Verify locked out error"]
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "test/inventory.spec.js",
|
|
41
|
+
"assertions": [
|
|
42
|
+
{
|
|
43
|
+
"ancestorTitles": ["Product Inventory"],
|
|
44
|
+
"title": "AUTH-104 User can browse all products",
|
|
45
|
+
"status": "passed",
|
|
46
|
+
"duration": 900,
|
|
47
|
+
"steps": ["Verify Products page title", "Count inventory items"]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"ancestorTitles": ["Product Inventory"],
|
|
51
|
+
"title": "AUTH-105 User can sort products by price",
|
|
52
|
+
"status": "passed",
|
|
53
|
+
"duration": 850,
|
|
54
|
+
"steps": ["Select sort by price low to high", "Verify prices ascending"]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"ancestorTitles": ["Product Inventory"],
|
|
58
|
+
"title": "AUTH-106 User can view product details",
|
|
59
|
+
"status": "passed",
|
|
60
|
+
"duration": 750,
|
|
61
|
+
"steps": ["Click on first product name", "Verify product detail page"]
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "test/cart.spec.js",
|
|
67
|
+
"assertions": [
|
|
68
|
+
{
|
|
69
|
+
"ancestorTitles": ["Cart Management"],
|
|
70
|
+
"title": "AUTH-107 User can add product to cart",
|
|
71
|
+
"status": "passed",
|
|
72
|
+
"duration": 1000,
|
|
73
|
+
"steps": ["Add to cart", "Verify cart badge"]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"ancestorTitles": ["Cart Management"],
|
|
77
|
+
"title": "AUTH-108 User can remove product from cart",
|
|
78
|
+
"status": "passed",
|
|
79
|
+
"duration": 950,
|
|
80
|
+
"steps": ["Remove from cart", "Verify empty"]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"ancestorTitles": ["Cart Management"],
|
|
84
|
+
"title": "AUTH-109 User can add multiple products to cart",
|
|
85
|
+
"status": "passed",
|
|
86
|
+
"duration": 1100,
|
|
87
|
+
"steps": ["Add products", "Verify count"]
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"name": "test/checkout.spec.js",
|
|
93
|
+
"assertions": [
|
|
94
|
+
{
|
|
95
|
+
"ancestorTitles": ["Checkout Flow"],
|
|
96
|
+
"title": "AUTH-110 User can complete checkout with valid information",
|
|
97
|
+
"status": "passed",
|
|
98
|
+
"duration": 1500,
|
|
99
|
+
"steps": ["Fill checkout", "Finish", "Verify confirmation"]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"ancestorTitles": ["Checkout Flow"],
|
|
103
|
+
"title": "AUTH-111 Checkout fails without required information",
|
|
104
|
+
"status": "passed",
|
|
105
|
+
"duration": 600,
|
|
106
|
+
"steps": ["Submit empty", "Verify validation"]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"ancestorTitles": ["Checkout Flow"],
|
|
110
|
+
"title": "AUTH-112 User can cancel checkout",
|
|
111
|
+
"status": "passed",
|
|
112
|
+
"duration": 700,
|
|
113
|
+
"steps": ["Cancel", "Verify cart"]
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"ancestorTitles": ["Checkout Flow"],
|
|
117
|
+
"title": "AUTH-113 Demo test that will be ignored in reporting",
|
|
118
|
+
"status": "pending",
|
|
119
|
+
"duration": 0,
|
|
120
|
+
"steps": [],
|
|
121
|
+
"ignore": true
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PlaywrightAssertionInput } from './report-builder';
|
|
2
|
+
export type PlaywrightMediaAttachment = {
|
|
3
|
+
name: string;
|
|
4
|
+
contentType: string;
|
|
5
|
+
body?: Buffer | string;
|
|
6
|
+
path?: string;
|
|
7
|
+
};
|
|
8
|
+
/** Prefer PNG / still images; skip video, trace, and QAnalyzer metadata JSON. */
|
|
9
|
+
export declare function isStillImageAttachment(att: PlaywrightMediaAttachment): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Upload still-image attachments for a failed test onto assertion meta.qa.
|
|
12
|
+
*/
|
|
13
|
+
export declare function enrichAssertionWithFailureScreenshots(assertion: PlaywrightAssertionInput, attachments: readonly PlaywrightMediaAttachment[] | undefined): Promise<void>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isStillImageAttachment = isStillImageAttachment;
|
|
4
|
+
exports.enrichAssertionWithFailureScreenshots = enrichAssertionWithFailureScreenshots;
|
|
5
|
+
/**
|
|
6
|
+
* Upload Playwright still-image attachments on failure (FR119).
|
|
7
|
+
* Skips video/trace; never throws into the test run.
|
|
8
|
+
*/
|
|
9
|
+
const forge_commons_1 = require("@qanalyzer/forge-commons");
|
|
10
|
+
const metadata_manager_1 = require("./metadata-manager");
|
|
11
|
+
function ensureQaMeta(assertion) {
|
|
12
|
+
if (!assertion.meta)
|
|
13
|
+
assertion.meta = {};
|
|
14
|
+
if (!assertion.meta.qa) {
|
|
15
|
+
assertion.meta.qa = {
|
|
16
|
+
framework: 'playwright',
|
|
17
|
+
host: { framework: 'playwright', reporter: '@qanalyzer/forge-playwright' },
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return assertion.meta.qa;
|
|
21
|
+
}
|
|
22
|
+
function pushAttachment(assertion, attachment) {
|
|
23
|
+
const qa = ensureQaMeta(assertion);
|
|
24
|
+
if (!qa.attachments)
|
|
25
|
+
qa.attachments = [];
|
|
26
|
+
qa.attachments.push(attachment);
|
|
27
|
+
}
|
|
28
|
+
/** Prefer PNG / still images; skip video, trace, and QAnalyzer metadata JSON. */
|
|
29
|
+
function isStillImageAttachment(att) {
|
|
30
|
+
const ct = (att.contentType ?? '').toLowerCase();
|
|
31
|
+
if (ct === metadata_manager_1.QA_METADATA_CONTENT_TYPE)
|
|
32
|
+
return false;
|
|
33
|
+
if (ct.startsWith('video/') || ct.includes('trace') || ct.includes('zip')) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (ct === 'image/png' || ct === 'image/jpeg' || ct === 'image/webp') {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
if (ct.startsWith('image/'))
|
|
40
|
+
return true;
|
|
41
|
+
const name = (att.name ?? '').toLowerCase();
|
|
42
|
+
if (name === 'screenshot' || /\.(png|jpe?g|webp)$/i.test(name))
|
|
43
|
+
return true;
|
|
44
|
+
if (att.path && /\.(png|jpe?g|webp)$/i.test(att.path))
|
|
45
|
+
return true;
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
function mimeFor(att) {
|
|
49
|
+
if (att.contentType && att.contentType !== 'application/octet-stream') {
|
|
50
|
+
return att.contentType;
|
|
51
|
+
}
|
|
52
|
+
const name = att.name || att.path || '';
|
|
53
|
+
if (/\.jpe?g$/i.test(name))
|
|
54
|
+
return 'image/jpeg';
|
|
55
|
+
if (/\.webp$/i.test(name))
|
|
56
|
+
return 'image/webp';
|
|
57
|
+
return 'image/png';
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Upload still-image attachments for a failed test onto assertion meta.qa.
|
|
61
|
+
*/
|
|
62
|
+
async function enrichAssertionWithFailureScreenshots(assertion, attachments) {
|
|
63
|
+
if (assertion.status !== 'failed')
|
|
64
|
+
return;
|
|
65
|
+
for (const att of attachments ?? []) {
|
|
66
|
+
if (!isStillImageAttachment(att))
|
|
67
|
+
continue;
|
|
68
|
+
try {
|
|
69
|
+
const fileName = att.name ||
|
|
70
|
+
att.path?.split(/[/\\]/).pop() ||
|
|
71
|
+
'screenshot.png';
|
|
72
|
+
const outcome = await (0, forge_commons_1.uploadAttachmentForQa)({
|
|
73
|
+
fileName,
|
|
74
|
+
mimeType: mimeFor(att),
|
|
75
|
+
content: att.body,
|
|
76
|
+
path: att.path,
|
|
77
|
+
issueKeySources: [assertion.title, assertion.fullName],
|
|
78
|
+
});
|
|
79
|
+
pushAttachment(assertion, outcome.attachment);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Never fail the Playwright run
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Programmatic helpers for Playwright tests (FR111).
|
|
3
|
+
* Prefer Jira issue keys in `test('AUTH-101 ...')` titles (FR43).
|
|
4
|
+
*
|
|
5
|
+
* Steps: use Playwright native `test.step()` — do **not** use `qa.step` (FR112).
|
|
6
|
+
*
|
|
7
|
+
* In a live Playwright run, metadata is attached via `test.info().attach`.
|
|
8
|
+
* Outside Playwright (unit tests), helpers use an in-process buffer.
|
|
9
|
+
*
|
|
10
|
+
* `qa.attach` with binary content/path uploads via Forge when configured (FR119).
|
|
11
|
+
*/
|
|
12
|
+
import { MetadataManager, QA_METADATA_CONTENT_TYPE } from './metadata-manager';
|
|
13
|
+
export type QaHelpers = {
|
|
14
|
+
title(value: string): void;
|
|
15
|
+
comment(value: string): void;
|
|
16
|
+
suite(value: string): void;
|
|
17
|
+
fields(values: Record<string, string>): void;
|
|
18
|
+
parameters(values: Record<string, string>): void;
|
|
19
|
+
ignore(): void;
|
|
20
|
+
/** Attach metadata; with content/path, attempts Forge upload (FR119). */
|
|
21
|
+
attach(attach: {
|
|
22
|
+
name?: string;
|
|
23
|
+
contentType?: string;
|
|
24
|
+
content?: string | Buffer;
|
|
25
|
+
path?: string;
|
|
26
|
+
issueKey?: string;
|
|
27
|
+
}): void | Promise<void>;
|
|
28
|
+
};
|
|
29
|
+
export declare const qa: QaHelpers;
|
|
30
|
+
export { MetadataManager, QA_METADATA_CONTENT_TYPE };
|
|
31
|
+
export type { QaMetaEntry } from './metadata-manager';
|
package/dist/helpers.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Programmatic helpers for Playwright tests (FR111).
|
|
4
|
+
* Prefer Jira issue keys in `test('AUTH-101 ...')` titles (FR43).
|
|
5
|
+
*
|
|
6
|
+
* Steps: use Playwright native `test.step()` — do **not** use `qa.step` (FR112).
|
|
7
|
+
*
|
|
8
|
+
* In a live Playwright run, metadata is attached via `test.info().attach`.
|
|
9
|
+
* Outside Playwright (unit tests), helpers use an in-process buffer.
|
|
10
|
+
*
|
|
11
|
+
* `qa.attach` with binary content/path uploads via Forge when configured (FR119).
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.QA_METADATA_CONTENT_TYPE = exports.MetadataManager = exports.qa = void 0;
|
|
15
|
+
const forge_commons_1 = require("@qanalyzer/forge-commons");
|
|
16
|
+
const metadata_manager_1 = require("./metadata-manager");
|
|
17
|
+
Object.defineProperty(exports, "MetadataManager", { enumerable: true, get: function () { return metadata_manager_1.MetadataManager; } });
|
|
18
|
+
Object.defineProperty(exports, "QA_METADATA_CONTENT_TYPE", { enumerable: true, get: function () { return metadata_manager_1.QA_METADATA_CONTENT_TYPE; } });
|
|
19
|
+
function tryCurrentTitle() {
|
|
20
|
+
try {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
22
|
+
const pw = require('@playwright/test');
|
|
23
|
+
return pw.test?.info?.()?.title;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function tryAttachMetadata(meta) {
|
|
30
|
+
try {
|
|
31
|
+
// Lazy require so unit tests run without a Playwright test context.
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
33
|
+
const pw = require('@playwright/test');
|
|
34
|
+
const info = pw.test?.info?.();
|
|
35
|
+
if (!info?.attach)
|
|
36
|
+
return false;
|
|
37
|
+
void info
|
|
38
|
+
.attach('qanalyzer-metadata.json', {
|
|
39
|
+
contentType: metadata_manager_1.QA_METADATA_CONTENT_TYPE,
|
|
40
|
+
body: Buffer.from(JSON.stringify(meta), 'utf8'),
|
|
41
|
+
})
|
|
42
|
+
.catch(() => {
|
|
43
|
+
// Never fail the test run
|
|
44
|
+
});
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function pushMeta(type, body, wire) {
|
|
52
|
+
if (tryAttachMetadata(wire))
|
|
53
|
+
return;
|
|
54
|
+
metadata_manager_1.MetadataManager.push(type, body);
|
|
55
|
+
}
|
|
56
|
+
exports.qa = {
|
|
57
|
+
title(value) {
|
|
58
|
+
pushMeta('qa-title', value, { title: value });
|
|
59
|
+
},
|
|
60
|
+
comment(value) {
|
|
61
|
+
pushMeta('qa-comment', value, { comment: value });
|
|
62
|
+
},
|
|
63
|
+
suite(value) {
|
|
64
|
+
pushMeta('qa-suite', value, { suite: value });
|
|
65
|
+
},
|
|
66
|
+
fields(values) {
|
|
67
|
+
pushMeta('qa-fields', values, { fields: values });
|
|
68
|
+
},
|
|
69
|
+
parameters(values) {
|
|
70
|
+
pushMeta('qa-parameters', values, { parameters: values });
|
|
71
|
+
},
|
|
72
|
+
ignore() {
|
|
73
|
+
pushMeta('qa-ignore', true, { ignore: true });
|
|
74
|
+
},
|
|
75
|
+
attach(attach) {
|
|
76
|
+
const mime = attach.contentType;
|
|
77
|
+
const hasBinary = attach.content !== undefined || Boolean(attach.path);
|
|
78
|
+
if (!hasBinary) {
|
|
79
|
+
const body = {
|
|
80
|
+
name: attach.name,
|
|
81
|
+
contentType: mime,
|
|
82
|
+
};
|
|
83
|
+
pushMeta('qa-attach', body, { attachments: [body] });
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
return (0, forge_commons_1.uploadAttachmentForQa)({
|
|
87
|
+
fileName: attach.name,
|
|
88
|
+
mimeType: mime,
|
|
89
|
+
content: attach.content,
|
|
90
|
+
path: attach.path,
|
|
91
|
+
issueKey: attach.issueKey,
|
|
92
|
+
issueKeySources: [attach.issueKey, tryCurrentTitle()],
|
|
93
|
+
})
|
|
94
|
+
.then((outcome) => {
|
|
95
|
+
const body = {
|
|
96
|
+
name: outcome.attachment.file_name ?? attach.name,
|
|
97
|
+
contentType: outcome.attachment.mime_type ?? mime,
|
|
98
|
+
size: outcome.attachment.size,
|
|
99
|
+
content_ref: outcome.attachment.content_ref,
|
|
100
|
+
};
|
|
101
|
+
pushMeta('qa-attach', body, { attachments: [body] });
|
|
102
|
+
})
|
|
103
|
+
.catch(() => {
|
|
104
|
+
const body = { name: attach.name, contentType: mime };
|
|
105
|
+
pushMeta('qa-attach', body, { attachments: [body] });
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { PlaywrightQaReporter, type PlaywrightQaOptions } from './reporter';
|
|
2
|
+
export { qa, MetadataManager, QA_METADATA_CONTENT_TYPE, type QaHelpers, type QaMetaEntry, } from './helpers';
|
|
3
|
+
export { toJestJsonReport, mapPlaywrightStatus, type PlaywrightAssertionInput, type PlaywrightSpecInput, } from './report-builder';
|
|
4
|
+
export { extractNativeSteps, type PlaywrightStepLike } from './step-extractor';
|
|
5
|
+
export { buildQaMetaFromResult } from './metadata-from-result';
|
|
6
|
+
import { PlaywrightQaReporter } from './reporter';
|
|
7
|
+
export default PlaywrightQaReporter;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildQaMetaFromResult = exports.extractNativeSteps = exports.mapPlaywrightStatus = exports.toJestJsonReport = exports.QA_METADATA_CONTENT_TYPE = exports.MetadataManager = exports.qa = exports.PlaywrightQaReporter = void 0;
|
|
4
|
+
var reporter_1 = require("./reporter");
|
|
5
|
+
Object.defineProperty(exports, "PlaywrightQaReporter", { enumerable: true, get: function () { return reporter_1.PlaywrightQaReporter; } });
|
|
6
|
+
var helpers_1 = require("./helpers");
|
|
7
|
+
Object.defineProperty(exports, "qa", { enumerable: true, get: function () { return helpers_1.qa; } });
|
|
8
|
+
Object.defineProperty(exports, "MetadataManager", { enumerable: true, get: function () { return helpers_1.MetadataManager; } });
|
|
9
|
+
Object.defineProperty(exports, "QA_METADATA_CONTENT_TYPE", { enumerable: true, get: function () { return helpers_1.QA_METADATA_CONTENT_TYPE; } });
|
|
10
|
+
var report_builder_1 = require("./report-builder");
|
|
11
|
+
Object.defineProperty(exports, "toJestJsonReport", { enumerable: true, get: function () { return report_builder_1.toJestJsonReport; } });
|
|
12
|
+
Object.defineProperty(exports, "mapPlaywrightStatus", { enumerable: true, get: function () { return report_builder_1.mapPlaywrightStatus; } });
|
|
13
|
+
var step_extractor_1 = require("./step-extractor");
|
|
14
|
+
Object.defineProperty(exports, "extractNativeSteps", { enumerable: true, get: function () { return step_extractor_1.extractNativeSteps; } });
|
|
15
|
+
var metadata_from_result_1 = require("./metadata-from-result");
|
|
16
|
+
Object.defineProperty(exports, "buildQaMetaFromResult", { enumerable: true, get: function () { return metadata_from_result_1.buildQaMetaFromResult; } });
|
|
17
|
+
const reporter_2 = require("./reporter");
|
|
18
|
+
exports.default = reporter_2.PlaywrightQaReporter;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type QaMetaWire } from '@qanalyzer/forge-commons';
|
|
2
|
+
import type { PlaywrightStepLike } from './step-extractor';
|
|
3
|
+
export type PlaywrightAttachmentLike = {
|
|
4
|
+
name: string;
|
|
5
|
+
contentType: string;
|
|
6
|
+
body?: Buffer | string;
|
|
7
|
+
/** Disk path when Playwright wrote the attachment to a file. */
|
|
8
|
+
path?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Merge `qa.*` helper attachments + native `test.step` into `meta.qa`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildQaMetaFromResult(input: {
|
|
14
|
+
attachments?: readonly PlaywrightAttachmentLike[];
|
|
15
|
+
steps?: readonly PlaywrightStepLike[];
|
|
16
|
+
}): QaMetaWire | undefined;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildQaMetaFromResult = buildQaMetaFromResult;
|
|
4
|
+
const forge_commons_1 = require("@qanalyzer/forge-commons");
|
|
5
|
+
const metadata_manager_1 = require("./metadata-manager");
|
|
6
|
+
const step_extractor_1 = require("./step-extractor");
|
|
7
|
+
/**
|
|
8
|
+
* Merge `qa.*` helper attachments + native `test.step` into `meta.qa`.
|
|
9
|
+
*/
|
|
10
|
+
function buildQaMetaFromResult(input) {
|
|
11
|
+
const acc = (0, forge_commons_1.createQaMetaAccumulator)();
|
|
12
|
+
for (const attachment of input.attachments ?? []) {
|
|
13
|
+
if (attachment.contentType !== metadata_manager_1.QA_METADATA_CONTENT_TYPE)
|
|
14
|
+
continue;
|
|
15
|
+
if (attachment.body == null)
|
|
16
|
+
continue;
|
|
17
|
+
try {
|
|
18
|
+
const raw = typeof attachment.body === 'string'
|
|
19
|
+
? attachment.body
|
|
20
|
+
: attachment.body.toString('utf8');
|
|
21
|
+
const message = JSON.parse(raw);
|
|
22
|
+
if (message.title)
|
|
23
|
+
(0, forge_commons_1.applyQaAnnotation)(acc, { type: 'qa-title', body: message.title });
|
|
24
|
+
if (message.comment) {
|
|
25
|
+
(0, forge_commons_1.applyQaAnnotation)(acc, { type: 'qa-comment', body: message.comment });
|
|
26
|
+
}
|
|
27
|
+
if (message.suite)
|
|
28
|
+
(0, forge_commons_1.applyQaAnnotation)(acc, { type: 'qa-suite', body: message.suite });
|
|
29
|
+
if (message.fields) {
|
|
30
|
+
(0, forge_commons_1.applyQaAnnotation)(acc, { type: 'qa-fields', body: message.fields });
|
|
31
|
+
}
|
|
32
|
+
if (message.parameters) {
|
|
33
|
+
(0, forge_commons_1.applyQaAnnotation)(acc, { type: 'qa-parameters', body: message.parameters });
|
|
34
|
+
}
|
|
35
|
+
if (message.ignore)
|
|
36
|
+
(0, forge_commons_1.applyQaAnnotation)(acc, { type: 'qa-ignore', body: true });
|
|
37
|
+
for (const att of message.attachments ?? []) {
|
|
38
|
+
(0, forge_commons_1.applyQaAnnotation)(acc, {
|
|
39
|
+
type: 'qa-attach',
|
|
40
|
+
body: { name: att.name, contentType: att.contentType },
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// ignore malformed metadata
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const nativeSteps = (0, step_extractor_1.extractNativeSteps)(input.steps);
|
|
49
|
+
for (const step of nativeSteps) {
|
|
50
|
+
acc.steps.push({ name: step.name, status: step.status });
|
|
51
|
+
}
|
|
52
|
+
return (0, forge_commons_1.toQaMetaWire)(acc, { framework: 'playwright', reporter: '@qanalyzer/forge-playwright' });
|
|
53
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-process metadata buffer for unit tests and when Playwright test.info()
|
|
3
|
+
* is unavailable. Live runs prefer test.info().attach (see helpers.ts).
|
|
4
|
+
*/
|
|
5
|
+
export type QaMetaEntry = {
|
|
6
|
+
type: string;
|
|
7
|
+
body: unknown;
|
|
8
|
+
};
|
|
9
|
+
export declare const MetadataManager: {
|
|
10
|
+
clear(): void;
|
|
11
|
+
push(type: string, body: unknown): void;
|
|
12
|
+
getEntries(): QaMetaEntry[];
|
|
13
|
+
};
|
|
14
|
+
/** Content type for metadata attachments read by the reporter (Story 2.7.2). */
|
|
15
|
+
export declare const QA_METADATA_CONTENT_TYPE = "application/qanalyzer.metadata+json";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* In-process metadata buffer for unit tests and when Playwright test.info()
|
|
4
|
+
* is unavailable. Live runs prefer test.info().attach (see helpers.ts).
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.QA_METADATA_CONTENT_TYPE = exports.MetadataManager = void 0;
|
|
8
|
+
const entries = [];
|
|
9
|
+
exports.MetadataManager = {
|
|
10
|
+
clear() {
|
|
11
|
+
entries.length = 0;
|
|
12
|
+
},
|
|
13
|
+
push(type, body) {
|
|
14
|
+
entries.push({ type, body });
|
|
15
|
+
},
|
|
16
|
+
getEntries() {
|
|
17
|
+
return [...entries];
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
/** Content type for metadata attachments read by the reporter (Story 2.7.2). */
|
|
21
|
+
exports.QA_METADATA_CONTENT_TYPE = 'application/qanalyzer.metadata+json';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { JestVitestJsonReport, QaMetaWire } from '@qanalyzer/forge-commons';
|
|
2
|
+
export type PlaywrightAssertionInput = {
|
|
3
|
+
ancestorTitles: string[];
|
|
4
|
+
title: string;
|
|
5
|
+
fullName?: string;
|
|
6
|
+
status: 'passed' | 'failed' | 'pending' | 'todo';
|
|
7
|
+
duration?: number;
|
|
8
|
+
failureMessages?: string[];
|
|
9
|
+
meta?: {
|
|
10
|
+
qa?: QaMetaWire;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type PlaywrightSpecInput = {
|
|
14
|
+
/** Spec file path */
|
|
15
|
+
name: string;
|
|
16
|
+
startTime?: number;
|
|
17
|
+
endTime?: number;
|
|
18
|
+
assertions: PlaywrightAssertionInput[];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Normalize collected Playwright specs into FR41 jest-json shape A.
|
|
22
|
+
*/
|
|
23
|
+
export declare function toJestJsonReport(specs: readonly PlaywrightSpecInput[], startTime?: number): JestVitestJsonReport;
|
|
24
|
+
/** Map Playwright TestResult.status → FR41 assertion status. */
|
|
25
|
+
export declare function mapPlaywrightStatus(status: string | undefined): PlaywrightAssertionInput['status'];
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toJestJsonReport = toJestJsonReport;
|
|
4
|
+
exports.mapPlaywrightStatus = mapPlaywrightStatus;
|
|
5
|
+
function mapAssertion(a) {
|
|
6
|
+
const fullName = a.fullName ??
|
|
7
|
+
(a.ancestorTitles.length > 0
|
|
8
|
+
? `${a.ancestorTitles.join(' ')} ${a.title}`
|
|
9
|
+
: a.title);
|
|
10
|
+
const assertion = {
|
|
11
|
+
ancestorTitles: a.ancestorTitles,
|
|
12
|
+
fullName,
|
|
13
|
+
title: a.title,
|
|
14
|
+
status: a.status,
|
|
15
|
+
duration: a.duration,
|
|
16
|
+
failureMessages: a.failureMessages ?? [],
|
|
17
|
+
};
|
|
18
|
+
if (a.meta?.qa) {
|
|
19
|
+
assertion.meta = { qa: a.meta.qa };
|
|
20
|
+
}
|
|
21
|
+
return assertion;
|
|
22
|
+
}
|
|
23
|
+
function fileStatus(assertions) {
|
|
24
|
+
return assertions.some((a) => a.status === 'failed') ? 'failed' : 'passed';
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Normalize collected Playwright specs into FR41 jest-json shape A.
|
|
28
|
+
*/
|
|
29
|
+
function toJestJsonReport(specs, startTime) {
|
|
30
|
+
const testResults = specs.map((spec) => {
|
|
31
|
+
const assertionResults = spec.assertions.map(mapAssertion);
|
|
32
|
+
return {
|
|
33
|
+
name: spec.name,
|
|
34
|
+
status: fileStatus(assertionResults),
|
|
35
|
+
startTime: spec.startTime,
|
|
36
|
+
endTime: spec.endTime,
|
|
37
|
+
assertionResults,
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
let numPassedTests = 0;
|
|
41
|
+
let numFailedTests = 0;
|
|
42
|
+
let numPendingTests = 0;
|
|
43
|
+
let numTodoTests = 0;
|
|
44
|
+
for (const file of testResults) {
|
|
45
|
+
for (const a of file.assertionResults ?? []) {
|
|
46
|
+
if (a.status === 'passed')
|
|
47
|
+
numPassedTests += 1;
|
|
48
|
+
else if (a.status === 'failed')
|
|
49
|
+
numFailedTests += 1;
|
|
50
|
+
else if (a.status === 'todo')
|
|
51
|
+
numTodoTests += 1;
|
|
52
|
+
else
|
|
53
|
+
numPendingTests += 1;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const numTotalTests = numPassedTests + numFailedTests + numPendingTests + numTodoTests;
|
|
57
|
+
const numFailedTestSuites = testResults.filter((t) => t.status === 'failed').length;
|
|
58
|
+
const numPassedTestSuites = testResults.length - numFailedTestSuites;
|
|
59
|
+
return {
|
|
60
|
+
numTotalTestSuites: testResults.length,
|
|
61
|
+
numPassedTestSuites,
|
|
62
|
+
numFailedTestSuites,
|
|
63
|
+
numPendingTestSuites: 0,
|
|
64
|
+
numTotalTests,
|
|
65
|
+
numPassedTests,
|
|
66
|
+
numFailedTests,
|
|
67
|
+
numPendingTests,
|
|
68
|
+
numTodoTests,
|
|
69
|
+
startTime,
|
|
70
|
+
success: numFailedTests === 0,
|
|
71
|
+
testResults,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** Map Playwright TestResult.status → FR41 assertion status. */
|
|
75
|
+
function mapPlaywrightStatus(status) {
|
|
76
|
+
if (status === 'passed')
|
|
77
|
+
return 'passed';
|
|
78
|
+
if (status === 'skipped')
|
|
79
|
+
return 'pending';
|
|
80
|
+
if (status === 'failed' || status === 'timedOut' || status === 'interrupted') {
|
|
81
|
+
return 'failed';
|
|
82
|
+
}
|
|
83
|
+
return 'pending';
|
|
84
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FullConfig, FullResult, Reporter, Suite, TestCase, TestResult, TestStep } from '@playwright/test/reporter';
|
|
2
|
+
import { type OptionsType } from '@qanalyzer/forge-commons';
|
|
3
|
+
export type PlaywrightQaOptions = OptionsType;
|
|
4
|
+
/**
|
|
5
|
+
* Playwright reporter for QAnalyzer.
|
|
6
|
+
*
|
|
7
|
+
* Configure:
|
|
8
|
+
* reporter: [['list'], ['@qanalyzer/forge-playwright', { mode: 'off' }]]
|
|
9
|
+
*
|
|
10
|
+
* Collects each test → FR41 shape A; native `test.step` → `meta.qa.steps`.
|
|
11
|
+
* On failure, still-image attachments are uploaded via Forge (FR119).
|
|
12
|
+
*/
|
|
13
|
+
export declare class PlaywrightQaReporter implements Reporter {
|
|
14
|
+
private readonly options;
|
|
15
|
+
private readonly byFile;
|
|
16
|
+
private readonly runStart;
|
|
17
|
+
private readonly pendingUploads;
|
|
18
|
+
private publishPromise;
|
|
19
|
+
constructor(options?: PlaywrightQaOptions);
|
|
20
|
+
onBegin(_config: FullConfig, _suite: Suite): void;
|
|
21
|
+
onStepBegin(_test: TestCase, _result: TestResult, _step: TestStep): void;
|
|
22
|
+
onTestEnd(test: TestCase, result: TestResult): void;
|
|
23
|
+
onEnd(_result: FullResult): Promise<void>;
|
|
24
|
+
private publish;
|
|
25
|
+
}
|
|
26
|
+
export default PlaywrightQaReporter;
|
package/dist/reporter.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlaywrightQaReporter = void 0;
|
|
4
|
+
const forge_commons_1 = require("@qanalyzer/forge-commons");
|
|
5
|
+
const enrich_screenshots_1 = require("./enrich-screenshots");
|
|
6
|
+
const metadata_from_result_1 = require("./metadata-from-result");
|
|
7
|
+
const report_builder_1 = require("./report-builder");
|
|
8
|
+
/**
|
|
9
|
+
* Playwright reporter for QAnalyzer.
|
|
10
|
+
*
|
|
11
|
+
* Configure:
|
|
12
|
+
* reporter: [['list'], ['@qanalyzer/forge-playwright', { mode: 'off' }]]
|
|
13
|
+
*
|
|
14
|
+
* Collects each test → FR41 shape A; native `test.step` → `meta.qa.steps`.
|
|
15
|
+
* On failure, still-image attachments are uploaded via Forge (FR119).
|
|
16
|
+
*/
|
|
17
|
+
class PlaywrightQaReporter {
|
|
18
|
+
options;
|
|
19
|
+
byFile = new Map();
|
|
20
|
+
runStart = Date.now();
|
|
21
|
+
pendingUploads = [];
|
|
22
|
+
publishPromise = null;
|
|
23
|
+
constructor(options = {}) {
|
|
24
|
+
this.options = options ?? {};
|
|
25
|
+
}
|
|
26
|
+
onBegin(_config, _suite) {
|
|
27
|
+
this.byFile.clear();
|
|
28
|
+
this.pendingUploads.length = 0;
|
|
29
|
+
}
|
|
30
|
+
onStepBegin(_test, _result, _step) {
|
|
31
|
+
// Steps are read from result.steps on onTestEnd (full tree available there)
|
|
32
|
+
}
|
|
33
|
+
onTestEnd(test, result) {
|
|
34
|
+
try {
|
|
35
|
+
const pathTitles = typeof test.titlePath === 'function' ? test.titlePath() : [test.title];
|
|
36
|
+
const ancestorTitles = pathTitles.slice(0, -1);
|
|
37
|
+
const title = test.title;
|
|
38
|
+
const fullName = ancestorTitles.length > 0
|
|
39
|
+
? `${ancestorTitles.join(' ')} ${title}`
|
|
40
|
+
: title;
|
|
41
|
+
const wire = (0, metadata_from_result_1.buildQaMetaFromResult)({
|
|
42
|
+
attachments: result.attachments,
|
|
43
|
+
steps: result.steps,
|
|
44
|
+
});
|
|
45
|
+
const failureMessages = (result.errors ?? [])
|
|
46
|
+
.map((e) => {
|
|
47
|
+
if (typeof e === 'string')
|
|
48
|
+
return e;
|
|
49
|
+
if (e && typeof e === 'object' && 'message' in e) {
|
|
50
|
+
return String(e.message ?? '');
|
|
51
|
+
}
|
|
52
|
+
return String(e);
|
|
53
|
+
})
|
|
54
|
+
.filter(Boolean);
|
|
55
|
+
const assertion = {
|
|
56
|
+
ancestorTitles,
|
|
57
|
+
title,
|
|
58
|
+
fullName,
|
|
59
|
+
status: (0, report_builder_1.mapPlaywrightStatus)(result.status),
|
|
60
|
+
duration: result.duration,
|
|
61
|
+
failureMessages,
|
|
62
|
+
};
|
|
63
|
+
if (wire) {
|
|
64
|
+
assertion.meta = { qa: wire };
|
|
65
|
+
}
|
|
66
|
+
const file = test.location?.file ??
|
|
67
|
+
test.file ??
|
|
68
|
+
'unknown';
|
|
69
|
+
const list = this.byFile.get(file) ?? [];
|
|
70
|
+
list.push(assertion);
|
|
71
|
+
this.byFile.set(file, list);
|
|
72
|
+
if (assertion.status === 'failed') {
|
|
73
|
+
this.pendingUploads.push((0, enrich_screenshots_1.enrichAssertionWithFailureScreenshots)(assertion, result.attachments).catch(() => {
|
|
74
|
+
// Never fail the Playwright run
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Never fail the Playwright run
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async onEnd(_result) {
|
|
83
|
+
if (this.publishPromise) {
|
|
84
|
+
await this.publishPromise;
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.publishPromise = this.publish();
|
|
88
|
+
await this.publishPromise;
|
|
89
|
+
}
|
|
90
|
+
async publish() {
|
|
91
|
+
try {
|
|
92
|
+
await Promise.all(this.pendingUploads);
|
|
93
|
+
forge_commons_1.QAnalyzerReporter.resetInstance();
|
|
94
|
+
const reporter = forge_commons_1.QAnalyzerReporter.getInstance({
|
|
95
|
+
...this.options,
|
|
96
|
+
mode: this.options.mode ?? forge_commons_1.ModeEnum.off,
|
|
97
|
+
});
|
|
98
|
+
const mode = reporter.getConfig().mode ?? forge_commons_1.ModeEnum.off;
|
|
99
|
+
if (mode === forge_commons_1.ModeEnum.off) {
|
|
100
|
+
this.byFile.clear();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const specs = [];
|
|
104
|
+
for (const [name, assertions] of this.byFile) {
|
|
105
|
+
if (assertions.length === 0)
|
|
106
|
+
continue;
|
|
107
|
+
specs.push({
|
|
108
|
+
name,
|
|
109
|
+
startTime: this.runStart,
|
|
110
|
+
endTime: Date.now(),
|
|
111
|
+
assertions,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
this.byFile.clear();
|
|
115
|
+
if (specs.length === 0)
|
|
116
|
+
return;
|
|
117
|
+
const report = (0, report_builder_1.toJestJsonReport)(specs, this.runStart);
|
|
118
|
+
await reporter.publishReport(report, {
|
|
119
|
+
format: 'jest-json',
|
|
120
|
+
launchName: this.options.launchName,
|
|
121
|
+
projectKey: this.options.projectKey,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
// Never fail the Playwright run because of reporter publish errors
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.PlaywrightQaReporter = PlaywrightQaReporter;
|
|
130
|
+
exports.default = PlaywrightQaReporter;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { QaMetaStepWire } from '@qanalyzer/forge-commons';
|
|
2
|
+
/** Minimal Playwright TestStep shape used by the extractor (avoids tight coupling in tests). */
|
|
3
|
+
export type PlaywrightStepLike = {
|
|
4
|
+
category: string;
|
|
5
|
+
title: string;
|
|
6
|
+
error?: unknown;
|
|
7
|
+
steps?: PlaywrightStepLike[];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Flatten native Playwright `test.step` hierarchy into FR41 `meta.qa.steps` (FR112 / NFR31).
|
|
11
|
+
* Skips hooks and non-`test.step` categories.
|
|
12
|
+
*/
|
|
13
|
+
export declare function extractNativeSteps(steps: readonly PlaywrightStepLike[] | undefined): QaMetaStepWire[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractNativeSteps = extractNativeSteps;
|
|
4
|
+
/**
|
|
5
|
+
* Flatten native Playwright `test.step` hierarchy into FR41 `meta.qa.steps` (FR112 / NFR31).
|
|
6
|
+
* Skips hooks and non-`test.step` categories.
|
|
7
|
+
*/
|
|
8
|
+
function extractNativeSteps(steps) {
|
|
9
|
+
const out = [];
|
|
10
|
+
let index = 0;
|
|
11
|
+
const walk = (list) => {
|
|
12
|
+
if (!list)
|
|
13
|
+
return;
|
|
14
|
+
for (const step of list) {
|
|
15
|
+
if (step.category !== 'test.step') {
|
|
16
|
+
walk(step.steps);
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
index += 1;
|
|
20
|
+
out.push({
|
|
21
|
+
id: `s${index}`,
|
|
22
|
+
stepType: 'text',
|
|
23
|
+
name: step.title,
|
|
24
|
+
status: step.error ? 'failed' : 'passed',
|
|
25
|
+
});
|
|
26
|
+
walk(step.steps);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
walk(steps);
|
|
30
|
+
return out;
|
|
31
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qanalyzer/forge-playwright",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "QAnalyzer Playwright reporter \u2014 ingest or file modes via @qanalyzer/forge-commons",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"qanalyzer",
|
|
7
|
+
"playwright",
|
|
8
|
+
"reporter",
|
|
9
|
+
"testing",
|
|
10
|
+
"jira"
|
|
11
|
+
],
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./helpers": {
|
|
20
|
+
"types": "./dist/helpers.d.ts",
|
|
21
|
+
"default": "./dist/helpers.js"
|
|
22
|
+
},
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"!dist/__tests__",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "npm run clean && npx tsc --project tsconfig.build.json && cp -R src/__fixtures__ dist/__fixtures__",
|
|
35
|
+
"clean": "rm -rf dist",
|
|
36
|
+
"test": "npm run build && node --test dist/__tests__/**/*.test.js",
|
|
37
|
+
"prepublishOnly": "npm test"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@qanalyzer/forge-commons": "^1.1.1"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@playwright/test": ">=1.40.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@playwright/test": "^1.54.1"
|
|
47
|
+
},
|
|
48
|
+
"license": "Apache-2.0"
|
|
49
|
+
}
|