@zohodesk/testinglibrary 0.4.63-n18-experimental → 0.4.65-n18-experimental

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.
@@ -51,7 +51,7 @@ let reporter = [['html', {
51
51
  open: openReportOn
52
52
  }], ['list'], ['json', {
53
53
  outputFile: _path.default.join(process.cwd(), 'uat', 'test-results', 'test-results.json')
54
- }], ['./custom-reporter.js']];
54
+ }], ['./custom-reporter.js'], ['./qc-custom-reporter.js']];
55
55
  if (customReporter) {
56
56
  reporter = [customReporter, ...reporter];
57
57
  }
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _fs = _interopRequireDefault(require("fs"));
9
+ var _codeFrame = require("@babel/code-frame");
10
+ class CustomJsonReporter {
11
+ constructor({
12
+ outputFile = 'playwright-custom-report.json'
13
+ } = {}) {
14
+ this.outputFile = outputFile;
15
+ this.rootSuite = null;
16
+ this.report = {
17
+ config: {},
18
+ suites: []
19
+ };
20
+ this.testResultsById = new Map();
21
+ }
22
+ onBegin = (config, suite) => {
23
+ this.rootSuite = suite;
24
+ this.report.config = config;
25
+ };
26
+ onTestEnd(test, result) {
27
+ var _result$errors, _result$steps;
28
+ const key = `${test.location.file}:${test.location.line}:${test.title}`;
29
+ const testResult = {
30
+ status: result.status,
31
+ attachments: result.attachments,
32
+ startTime: result.startTime,
33
+ retry: result.retry,
34
+ stderr: result.stderr,
35
+ stdout: result.stdout,
36
+ workerIndex: result.workerIndex,
37
+ duration: result.duration,
38
+ errors: ((_result$errors = result.errors) === null || _result$errors === void 0 ? void 0 : _result$errors.map(({
39
+ message,
40
+ stack,
41
+ snippet
42
+ }) => ({
43
+ message,
44
+ stack,
45
+ snippet
46
+ }))) ?? [],
47
+ steps: ((_result$steps = result.steps) === null || _result$steps === void 0 ? void 0 : _result$steps.map(extractMergedSteps)) ?? []
48
+ };
49
+ const existingResults = this.testResultsById.get(key) ?? [];
50
+ this.testResultsById.set(key, [...existingResults, testResult]);
51
+ }
52
+ onEnd() {
53
+ var _this$rootSuite;
54
+ const testSuites = ((_this$rootSuite = this.rootSuite) === null || _this$rootSuite === void 0 || (_this$rootSuite = _this$rootSuite.suites) === null || _this$rootSuite === void 0 || (_this$rootSuite = _this$rootSuite[0]) === null || _this$rootSuite === void 0 ? void 0 : _this$rootSuite.suites) ?? [];
55
+ const extracted = testSuites.map(suite => extractMergedSuite(suite, this.testResultsById));
56
+ this.report.suites.push(...extracted);
57
+ _fs.default.writeFileSync(this.outputFile, JSON.stringify(this.report, null, 2));
58
+ console.log(`Custom JSON report written to: ${this.outputFile}`);
59
+ }
60
+ }
61
+ exports.default = CustomJsonReporter;
62
+ const extractMergedSuite = (suite, testResultsById) => {
63
+ var _suite$suites;
64
+ const specMap = new Map();
65
+ for (const test of suite.tests ?? []) {
66
+ const existingSpec = specMap.get(test.title);
67
+ if (existingSpec) {
68
+ const newTestInfo = extractTestDetails(test, testResultsById);
69
+ existingSpec.tests.push(newTestInfo);
70
+ } else {
71
+ const newSpec = createSpecEntry(test, testResultsById);
72
+ specMap.set(test.title, newSpec);
73
+ }
74
+ }
75
+ return {
76
+ title: suite.title,
77
+ location: suite.location,
78
+ ...(suite.location && {
79
+ snippet: formSnippet(suite.location)
80
+ }),
81
+ ...(((_suite$suites = suite.suites) === null || _suite$suites === void 0 ? void 0 : _suite$suites.length) > 0 && {
82
+ suites: suite.suites.map(child => extractMergedSuite(child, testResultsById))
83
+ }),
84
+ ...(specMap.size > 0 && {
85
+ specs: Array.from(specMap.values())
86
+ })
87
+ };
88
+ };
89
+ const createSpecEntry = (test, testResultsById) => ({
90
+ title: test.title,
91
+ location: test.location,
92
+ ...(test.location && {
93
+ snippet: formSnippet(test.location)
94
+ }),
95
+ tests: [extractTestDetails(test, testResultsById)]
96
+ });
97
+ const extractTestDetails = (test, testResultsById) => {
98
+ var _test$location, _test$location2;
99
+ const key = `${(_test$location = test.location) === null || _test$location === void 0 ? void 0 : _test$location.file}:${(_test$location2 = test.location) === null || _test$location2 === void 0 ? void 0 : _test$location2.line}:${test.title}`;
100
+ return {
101
+ annotations: test.annotations,
102
+ expectedStatus: test.expectedStatus,
103
+ timeout: test.timeout,
104
+ retries: test.retries,
105
+ tags: test.tags,
106
+ results: testResultsById.get(key) ?? [],
107
+ status: test.outcome()
108
+ };
109
+ };
110
+ const extractMergedSteps = step => ({
111
+ title: step.title,
112
+ duration: step.duration,
113
+ ...(step.error && {
114
+ error: {
115
+ message: step.error.message,
116
+ stack: step.error.stack,
117
+ snippet: step.error.snippet
118
+ }
119
+ }),
120
+ location: step.location,
121
+ status: step.status,
122
+ ...(step.location && {
123
+ snippet: formSnippet(step.location)
124
+ }),
125
+ ...(step.steps && step.steps.length > 0 && {
126
+ steps: step.steps.map(subStep => extractMergedSteps(subStep))
127
+ })
128
+ });
129
+ const formSnippet = location => {
130
+ if (!(location !== null && location !== void 0 && location.file)) return '';
131
+ try {
132
+ const raw = _fs.default.readFileSync(location.file, 'utf8');
133
+ return (0, _codeFrame.codeFrameColumns)(raw, {
134
+ start: {
135
+ line: location.line,
136
+ column: location.column
137
+ }
138
+ }, {
139
+ linesAbove: 2,
140
+ linesBelow: 2,
141
+ highlightCode: true
142
+ });
143
+ } catch {
144
+ return '';
145
+ }
146
+ };
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.4.63-n18-experimental",
3
+ "version": "0.4.65-n18-experimental",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@zohodesk/testinglibrary",
9
- "version": "0.4.63-n18-experimental",
9
+ "version": "0.4.65-n18-experimental",
10
10
  "hasInstallScript": true,
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
+ "@babel/code-frame": "7.27.1",
13
14
  "@babel/preset-react": "7.22.5",
14
15
  "@cucumber/cucumber": "11.2.0",
15
- "@playwright/test": "1.52.0",
16
+ "@playwright/test": "1.51.1",
16
17
  "@reportportal/agent-js-playwright": "5.1.11",
17
18
  "@testing-library/jest-dom": "5.11.9",
18
19
  "@testing-library/react": "11.2.7",
@@ -23,7 +24,7 @@
23
24
  "jest": "29.6.2",
24
25
  "jest-environment-jsdom": "29.6.2",
25
26
  "msw": "1.2.3",
26
- "playwright": "1.52.0",
27
+ "playwright": "1.51.1",
27
28
  "playwright-bdd": "8.2.1",
28
29
  "supports-color": "8.1.1"
29
30
  },
@@ -98,13 +99,14 @@
98
99
  }
99
100
  },
100
101
  "node_modules/@babel/code-frame": {
101
- "version": "7.26.2",
102
- "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz",
103
- "integrity": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==",
102
+ "version": "7.27.1",
103
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz",
104
+ "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==",
105
+ "license": "MIT",
104
106
  "dependencies": {
105
- "@babel/helper-validator-identifier": "^7.25.9",
107
+ "@babel/helper-validator-identifier": "^7.27.1",
106
108
  "js-tokens": "^4.0.0",
107
- "picocolors": "^1.0.0"
109
+ "picocolors": "^1.1.1"
108
110
  },
109
111
  "engines": {
110
112
  "node": ">=6.9.0"
@@ -359,9 +361,10 @@
359
361
  }
360
362
  },
361
363
  "node_modules/@babel/helper-validator-identifier": {
362
- "version": "7.25.9",
363
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz",
364
- "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==",
364
+ "version": "7.27.1",
365
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz",
366
+ "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==",
367
+ "license": "MIT",
365
368
  "engines": {
366
369
  "node": ">=6.9.0"
367
370
  }
@@ -3092,12 +3095,12 @@
3092
3095
  }
3093
3096
  },
3094
3097
  "node_modules/@playwright/test": {
3095
- "version": "1.52.0",
3096
- "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.52.0.tgz",
3097
- "integrity": "sha512-uh6W7sb55hl7D6vsAeA+V2p5JnlAqzhqFyF0VcJkKZXkgnFcVG9PziERRHQfPLfNGx1C292a4JqbWzhR8L4R1g==",
3098
+ "version": "1.51.1",
3099
+ "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.51.1.tgz",
3100
+ "integrity": "sha512-nM+kEaTSAoVlXmMPH10017vn3FSiFqr/bh4fKg9vmAdMfd9SDqRZNvPSiAHADc/itWak+qPvMPZQOPwCBW7k7Q==",
3098
3101
  "license": "Apache-2.0",
3099
3102
  "dependencies": {
3100
- "playwright": "1.52.0"
3103
+ "playwright": "1.51.1"
3101
3104
  },
3102
3105
  "bin": {
3103
3106
  "playwright": "cli.js"
@@ -8658,12 +8661,12 @@
8658
8661
  }
8659
8662
  },
8660
8663
  "node_modules/playwright": {
8661
- "version": "1.52.0",
8662
- "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.52.0.tgz",
8663
- "integrity": "sha512-JAwMNMBlxJ2oD1kce4KPtMkDeKGHQstdpFPcPH3maElAXon/QZeTvtsfXmTMRyO9TslfoYOXkSsvao2nE1ilTw==",
8664
+ "version": "1.51.1",
8665
+ "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.51.1.tgz",
8666
+ "integrity": "sha512-kkx+MB2KQRkyxjYPc3a0wLZZoDczmppyGJIvQ43l+aZihkaVvmu/21kiyaHeHjiFxjxNNFnUncKmcGIyOojsaw==",
8664
8667
  "license": "Apache-2.0",
8665
8668
  "dependencies": {
8666
- "playwright-core": "1.52.0"
8669
+ "playwright-core": "1.51.1"
8667
8670
  },
8668
8671
  "bin": {
8669
8672
  "playwright": "cli.js"
@@ -8831,9 +8834,9 @@
8831
8834
  }
8832
8835
  },
8833
8836
  "node_modules/playwright-core": {
8834
- "version": "1.52.0",
8835
- "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.52.0.tgz",
8836
- "integrity": "sha512-l2osTgLXSMeuLZOML9qYODUQoPPnUsKsb5/P6LJ2e6uPKXUdPK5WYhN4z03G+YNbWmGDY4YENauNu4ZKczreHg==",
8837
+ "version": "1.51.1",
8838
+ "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.51.1.tgz",
8839
+ "integrity": "sha512-/crRMj8+j/Nq5s8QcvegseuyeZPxpQCZb6HNk3Sos3BlZyAknRjoyJPFWkpNn8v0+P3WiwqFF8P+zQo4eqiNuw==",
8837
8840
  "license": "Apache-2.0",
8838
8841
  "bin": {
8839
8842
  "playwright-core": "cli.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.4.63-n18-experimental",
3
+ "version": "0.4.65-n18-experimental",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -21,9 +21,10 @@
21
21
  "author": "",
22
22
  "license": "ISC",
23
23
  "dependencies": {
24
+ "@babel/code-frame": "7.27.1",
24
25
  "@babel/preset-react": "7.22.5",
25
26
  "@cucumber/cucumber": "11.2.0",
26
- "@playwright/test": "1.52.0",
27
+ "@playwright/test": "1.51.1",
27
28
  "@reportportal/agent-js-playwright": "5.1.11",
28
29
  "@testing-library/jest-dom": "5.11.9",
29
30
  "@testing-library/react": "11.2.7",
@@ -34,9 +35,9 @@
34
35
  "jest": "29.6.2",
35
36
  "jest-environment-jsdom": "29.6.2",
36
37
  "msw": "1.2.3",
37
- "playwright": "1.52.0",
38
- "supports-color": "8.1.1",
39
- "playwright-bdd": "8.2.1"
38
+ "playwright": "1.51.1",
39
+ "playwright-bdd": "8.2.1",
40
+ "supports-color": "8.1.1"
40
41
  },
41
42
  "bin": {
42
43
  "ZDTestingFramework": "./bin/cli.js"
@@ -8,7 +8,10 @@ export default defineConfig({
8
8
  outputDir: path.join(process.cwd(), 'uat', 'test-results'),
9
9
  fullyParallel: true,
10
10
  retries: process.env.CI ? 2 : 0,
11
- reporter: [['html', { outputFolder: path.join(process.cwd(), 'uat', 'playwright-report'), open: "always" }]],
11
+ reporter: [
12
+ ['html', { outputFolder: path.join(process.cwd(), 'uat', 'playwright-report'), open: "always" }],
13
+ ['./src/core/playwright/setup/my-custom-reporter.js']
14
+ ],
12
15
  timeout: 60 * 1000,
13
16
  expect: {
14
17
  timeout: 5 * 1000,