playwright-ctrf-json-reporter 0.0.1 → 0.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playwright-ctrf-json-reporter",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,10 +0,0 @@
1
- import { FullResult, Reporter, TestCase, TestResult } from "@playwright/test/reporter";
2
- declare class MyReporter implements Reporter {
3
- private ctrfReport;
4
- constructor();
5
- onTestEnd(test: TestCase, result: TestResult): void;
6
- onEnd(result: FullResult): void;
7
- private updateCtrfResultsFromAfterSpecResults;
8
- private writeToFile;
9
- }
10
- export default MyReporter;
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fs = require("fs");
4
- class MyReporter {
5
- constructor() {
6
- this.ctrfReport = {
7
- results: {
8
- tool: {
9
- name: "playwright",
10
- },
11
- totals: {
12
- suites: 0,
13
- tests: 0,
14
- passed: 0,
15
- failed: 0,
16
- pending: 0,
17
- skipped: 0,
18
- timedOut: 0,
19
- interrupted: 0,
20
- other: 0,
21
- },
22
- tests: [],
23
- },
24
- };
25
- }
26
- // onBegin(config: FullConfig, suite: Suite) {
27
- // console.log(
28
- // `Starting the run with my custom reporter ${
29
- // suite.allTests().length
30
- // } tests`
31
- // );
32
- // }
33
- // onTestBegin(test: TestCase, result: TestResult) {
34
- // console.log(`Starting test ${test.title}`);
35
- // }
36
- onTestEnd(test, result) {
37
- this.updateCtrfResultsFromAfterSpecResults(test, result, this.ctrfReport);
38
- // console.log(`Finished test ${test.title}: ${result.status}`);
39
- }
40
- onEnd(result) {
41
- this.writeToFile("playwright-ctrf-json-report.json", this.ctrfReport);
42
- // console.log(`Finished the run: ${result.status}`);
43
- }
44
- updateCtrfResultsFromAfterSpecResults(testCase, testResult, ctrfReport) {
45
- ctrfReport.results.tests.push({
46
- name: testCase.title,
47
- status: testResult.status,
48
- duration: testResult.duration,
49
- });
50
- ctrfReport.results.totals.tests++;
51
- switch (testResult.status) {
52
- case "passed":
53
- ctrfReport.results.totals.passed++;
54
- break;
55
- case "failed":
56
- ctrfReport.results.totals.failed++;
57
- break;
58
- case "skipped":
59
- ctrfReport.results.totals.skipped++;
60
- break;
61
- case "interrupted":
62
- ctrfReport.results.totals.interrupted++;
63
- break;
64
- case "timedOut":
65
- ctrfReport.results.totals.timedOut++;
66
- break;
67
- default:
68
- break;
69
- }
70
- }
71
- writeToFile(filename, data) {
72
- const str = JSON.stringify(data, null, 2);
73
- try {
74
- fs.writeFileSync(filename, str + "\n");
75
- console.log("playwright-ctrf-json-report: successfully written ctrf json report to %s", filename);
76
- }
77
- catch (error) {
78
- console.error("Error writing ctrf json report:", error);
79
- }
80
- }
81
- }
82
- exports.default = MyReporter;