playwright-ctrf-json-reporter 0.0.13 → 0.0.15
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/README.md +31 -11
- package/dist/generate-report.js +11 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
> Save Playwright test results as a JSON file
|
|
4
4
|
|
|
5
|
+

|
|
6
|
+
[](https://github.com/ctrf-io/playwright-ctrf-json-report/actions/workflows/main.yaml)
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
|
|
5
11
|
A Playwright JSON test reporter to create test reports that follow the CTRF standard.
|
|
6
12
|
|
|
7
13
|
[Common Test Report Format](https://ctrf.io) ensures the generation of uniform JSON test reports, independent of programming languages or test framework in use.
|
|
@@ -22,7 +28,7 @@ The only way we can grow CTRF is with your help and the support of the software
|
|
|
22
28
|
- Give this repository a star ⭐⭐⭐⭐⭐⭐
|
|
23
29
|
- Follow the CTRF [GitHub organisation](https://github.com/ctrf-io)
|
|
24
30
|
- Clap for our medium articles (30 times each) 👏
|
|
25
|
-
- Share
|
|
31
|
+
- Share our [libraries](https://github.com/orgs/ctrf-io/repositories), our [homepage](https://www.ctrf.io/), or [Medium articles](https://medium.com/@ma11hewthomas)
|
|
26
32
|
- Maybe even write a blog about us!
|
|
27
33
|
- Try our [tools](https://github.com/orgs/ctrf-io/repositories)
|
|
28
34
|
|
|
@@ -67,16 +73,6 @@ The only way we can grow CTRF is with your help and the support of the software
|
|
|
67
73
|
}
|
|
68
74
|
```
|
|
69
75
|
|
|
70
|
-
## What is CTRF?
|
|
71
|
-
|
|
72
|
-
CTRF is a universal JSON test report schema that addresses the lack of a standardized format for JSON test reports.
|
|
73
|
-
|
|
74
|
-
**Consistency Across Tools:** Different testing tools and frameworks often produce reports in varied formats. CTRF ensures a uniform structure, making it easier to understand and compare reports, regardless of the testing tool used.
|
|
75
|
-
|
|
76
|
-
**Language and Framework Agnostic:** It provides a universal reporting schema that works seamlessly with any programming language and testing framework.
|
|
77
|
-
|
|
78
|
-
**Facilitates Better Analysis:** With a standardized format, programatically analyzing test outcomes across multiple platforms becomes more straightforward.
|
|
79
|
-
|
|
80
76
|
## Installation
|
|
81
77
|
|
|
82
78
|
```bash
|
|
@@ -130,6 +126,20 @@ reporter: [
|
|
|
130
126
|
|
|
131
127
|
A comprehensive report is generated by default, with the exception of screenshots, which you must explicitly set to true.
|
|
132
128
|
|
|
129
|
+
## Merge reports
|
|
130
|
+
|
|
131
|
+
When running tests in parallel, each test shard has its own test report. If you want to have a combined report showing all the test results from all the shards, you can merge them.
|
|
132
|
+
|
|
133
|
+
The [ctrf-cli](https://github.com/ctrf-io/ctrf-cli) package provides a method to merge multiple ctrf json files into a single file.
|
|
134
|
+
|
|
135
|
+
After executing your tests, use the following command:
|
|
136
|
+
|
|
137
|
+
```sh
|
|
138
|
+
npx ctrf merge <directory>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Replace directory with the path to the directory containing the CTRF reports you want to merge.
|
|
142
|
+
|
|
133
143
|
## Test Object Properties
|
|
134
144
|
|
|
135
145
|
The test object in the report includes the following [CTRF properties](https://ctrf.io/docs/schema/test):
|
|
@@ -225,6 +235,16 @@ test('example test', async ({ page }) => {
|
|
|
225
235
|
|
|
226
236
|
The browser metadata file must be called metadata.json and contain properties name and version in the body.
|
|
227
237
|
|
|
238
|
+
## What is CTRF?
|
|
239
|
+
|
|
240
|
+
CTRF is a universal JSON test report schema that addresses the lack of a standardized format for JSON test reports.
|
|
241
|
+
|
|
242
|
+
**Consistency Across Tools:** Different testing tools and frameworks often produce reports in varied formats. CTRF ensures a uniform structure, making it easier to understand and compare reports, regardless of the testing tool used.
|
|
243
|
+
|
|
244
|
+
**Language and Framework Agnostic:** It provides a universal reporting schema that works seamlessly with any programming language and testing framework.
|
|
245
|
+
|
|
246
|
+
**Facilitates Better Analysis:** With a standardized format, programatically analyzing test outcomes across multiple platforms becomes more straightforward.
|
|
247
|
+
|
|
228
248
|
## Support Us
|
|
229
249
|
|
|
230
250
|
If you find this project useful, consider giving it a GitHub star ⭐ It means a lot to us.
|
package/dist/generate-report.js
CHANGED
|
@@ -67,8 +67,10 @@ class GenerateCtrfReport {
|
|
|
67
67
|
onEnd() {
|
|
68
68
|
this.ctrfReport.results.summary.stop = Date.now();
|
|
69
69
|
if (this.suite !== undefined) {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
if (this.suite.allTests().length > 0) {
|
|
71
|
+
this.processSuite(this.suite);
|
|
72
|
+
this.ctrfReport.results.summary.suites = this.countSuites(this.suite);
|
|
73
|
+
}
|
|
72
74
|
}
|
|
73
75
|
this.writeReportToFile(this.ctrfReport);
|
|
74
76
|
}
|
|
@@ -81,9 +83,14 @@ class GenerateCtrfReport {
|
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
processTest(testCase) {
|
|
86
|
+
if (testCase.results.length === 0) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
84
89
|
const latestResult = testCase.results[testCase.results.length - 1];
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
if (latestResult !== undefined) {
|
|
91
|
+
this.updateCtrfTestResultsFromTestResult(testCase, latestResult, this.ctrfReport);
|
|
92
|
+
this.updateSummaryFromTestResult(latestResult, this.ctrfReport);
|
|
93
|
+
}
|
|
87
94
|
}
|
|
88
95
|
setFilename(filename) {
|
|
89
96
|
if (filename.endsWith('.json')) {
|