@zohodesk/testinglibrary 0.4.74-n18-experimental → 0.4.75-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.4.74-n18-experimental",
3
+ "version": "0.4.75-n18-experimental",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -21,10 +21,9 @@
21
21
  "author": "",
22
22
  "license": "ISC",
23
23
  "dependencies": {
24
- "@babel/code-frame": "7.27.1",
25
24
  "@babel/preset-react": "7.22.5",
26
- "@cucumber/cucumber": "11.3.0",
27
- "@playwright/test": "1.53.2",
25
+ "@cucumber/cucumber": "11.2.0",
26
+ "@playwright/test": "1.52.0",
28
27
  "@reportportal/agent-js-playwright": "5.1.11",
29
28
  "@testing-library/jest-dom": "5.11.9",
30
29
  "@testing-library/react": "11.2.7",
@@ -35,9 +34,9 @@
35
34
  "jest": "29.6.2",
36
35
  "jest-environment-jsdom": "29.6.2",
37
36
  "msw": "1.2.3",
38
- "playwright": "1.53.2",
37
+ "playwright": "1.52.0",
39
38
  "supports-color": "8.1.1",
40
- "playwright-bdd": "8.3.1"
39
+ "playwright-bdd": "8.2.1"
41
40
  },
42
41
  "bin": {
43
42
  "ZDTestingFramework": "./bin/cli.js"
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.additionProfiles = additionProfiles;
7
- var _getUsers = require("./auth/getUsers");
8
- function additionProfiles(tags, editionInfo, betaFeature, portalInfo) {
9
- const additionalProfileTags = tags.filter(tag => tag.startsWith('@additional_profile_'));
10
- let additionalProfileActors = [];
11
- if (additionalProfileTags.length > 0 && editionInfo) {
12
- additionalProfileActors = additionalProfileTags.map(tag => {
13
- const additionalProfile = tag.replace('@additional_profile_', '');
14
- return (0, _getUsers.getUserForSelectedEditionAndProfile)(editionInfo, additionalProfile, betaFeature, portalInfo);
15
- });
16
- }
17
- return additionalProfileActors;
18
- }
@@ -1,291 +0,0 @@
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 _path = _interopRequireDefault(require("path"));
10
- var _codeFrame = require("@babel/code-frame");
11
- class CustomJsonReporter {
12
- constructor({
13
- outputFile = 'test-results.json'
14
- } = {}) {
15
- this.outputFile = _path.default.resolve(process.cwd(), 'uat/test-results/', outputFile);
16
- this.rootSuite = null;
17
- this.report = {
18
- config: {},
19
- suites: []
20
- };
21
- this.testResultsById = new Map();
22
- }
23
- onBegin = (config, suite) => {
24
- this.rootSuite = suite;
25
- this.report.config = config;
26
- };
27
- onTestEnd(test, result) {
28
- var _result$errors, _result$steps;
29
- const key = `${test.location.file}:${test.location.line}:${test.title}`;
30
- const testResult = {
31
- status: result.status,
32
- attachments: result.attachments,
33
- startTime: result.startTime,
34
- retry: result.retry,
35
- stderr: result.stderr.map(err => stdioEntry(err)),
36
- stdout: result.stdout.map(out => stdioEntry(out)),
37
- workerIndex: result.workerIndex,
38
- duration: result.duration,
39
- error: result.error,
40
- errors: (_result$errors = result.errors) === null || _result$errors === void 0 ? void 0 : _result$errors.map(processError),
41
- steps: ((_result$steps = result.steps) === null || _result$steps === void 0 ? void 0 : _result$steps.map(step => extractMergedSteps(this.report.config.rootDir, step))) ?? []
42
- };
43
- const existingResults = this.testResultsById.get(key) ?? [];
44
- this.testResultsById.set(key, [...existingResults, testResult]);
45
- }
46
- onEnd() {
47
- var _this$rootSuite;
48
- (_this$rootSuite = this.rootSuite) === null || _this$rootSuite === void 0 || (_this$rootSuite = _this$rootSuite.suites) === null || _this$rootSuite === void 0 || _this$rootSuite.map(suite => {
49
- const extracted = suite.suites.map(suite => extractMergedSuite(this.report.config.rootDir, suite, this.testResultsById));
50
- this.report.suites.push(...extracted);
51
- });
52
- const writableStream = _fs.default.createWriteStream(this.outputFile);
53
- writableStream.write('{\n');
54
- writableStream.write(` "config": ${JSON.stringify(this.report.config, null, 2)},\n`);
55
- writableStream.write(' "suites": [\n');
56
- for (let i = 0; i < this.report.suites.length; i++) {
57
- const suite = this.report.suites[i];
58
- let suiteStr = JSON.stringify(suite, null, 2).split('\n').map(line => ' ' + line).join('\n');
59
- if (i < this.report.suites.length - 1) {
60
- suiteStr += ',';
61
- }
62
- suiteStr += '\n';
63
- writableStream.write(suiteStr);
64
- }
65
- writableStream.write(' ]\n');
66
- writableStream.write('}\n');
67
- writableStream.end();
68
- console.log(`Custom JSON report written to: ${this.outputFile}`);
69
- }
70
- }
71
- exports.default = CustomJsonReporter;
72
- const extractMergedSuite = (rootDir, suite, testResultsById) => {
73
- var _suite$suites;
74
- const specMap = new Map();
75
- for (const test of suite.tests ?? []) {
76
- const existingSpec = specMap.get(test.title);
77
- if (existingSpec) {
78
- const newTestInfo = extractTestDetails(test, testResultsById);
79
- existingSpec.tests.push(newTestInfo);
80
- } else {
81
- const newSpec = createSpecEntry(rootDir, test, testResultsById);
82
- specMap.set(test.title, newSpec);
83
- }
84
- }
85
- return {
86
- title: suite.title,
87
- ...parseLocation(rootDir, suite.location),
88
- ...(suite.location && {
89
- snippet: formSnippet(rootDir, suite.location)
90
- }),
91
- ...(((_suite$suites = suite.suites) === null || _suite$suites === void 0 ? void 0 : _suite$suites.length) > 0 && {
92
- suites: suite.suites.map(child => extractMergedSuite(rootDir, child, testResultsById))
93
- }),
94
- ...(specMap.size > 0 && {
95
- specs: Array.from(specMap.values())
96
- })
97
- };
98
- };
99
- const createSpecEntry = (rootDir, test, testResultsById) => ({
100
- title: test.title,
101
- ...parseLocation(rootDir, test.location),
102
- ...(test.location && {
103
- snippet: formSnippet(test.location)
104
- }),
105
- tests: [extractTestDetails(test, testResultsById)]
106
- });
107
- const extractTestDetails = (test, testResultsById) => {
108
- var _test$location, _test$location2;
109
- 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}`;
110
- return {
111
- annotations: test.annotations,
112
- expectedStatus: test.expectedStatus,
113
- timeout: test.timeout,
114
- retries: test.retries,
115
- tags: test.tags,
116
- results: testResultsById.get(key) ?? [],
117
- status: test.outcome()
118
- };
119
- };
120
- const extractMergedSteps = (rootDir, step) => ({
121
- title: step.title,
122
- duration: step.duration,
123
- ...(step.error && {
124
- error: {
125
- message: step.error.message,
126
- stack: step.error.stack,
127
- snippet: step.error.snippet
128
- }
129
- }),
130
- ...parseLocation(rootDir, step.location),
131
- status: step.status,
132
- ...(step.location && {
133
- snippet: formSnippet(rootDir, step.location)
134
- }),
135
- ...(step.steps && step.steps.length > 0 && {
136
- steps: step.steps.map(subStep => extractMergedSteps(rootDir, subStep))
137
- })
138
- });
139
- const formSnippet = (rootDir, location) => {
140
- if (location && !(location !== null && location !== void 0 && location.file)) return '';
141
- try {
142
- const {
143
- file,
144
- line,
145
- column
146
- } = parseLocation(rootDir, location, false);
147
- const raw = _fs.default.readFileSync(file, 'utf8');
148
- return (0, _codeFrame.codeFrameColumns)(raw, {
149
- start: {
150
- line,
151
- column
152
- }
153
- }, {
154
- linesAbove: 2,
155
- linesBelow: 2,
156
- highlightCode: true
157
- });
158
- } catch {
159
- return '';
160
- }
161
- };
162
- const parseLocation = (rootDir, {
163
- file,
164
- line,
165
- column
166
- } = {}, isRelative = true) => file ? {
167
- file: isRelative ? _path.default.relative(rootDir, file) : file,
168
- line,
169
- column
170
- } : {};
171
- const stdioEntry = s => typeof s === 'string' ? {
172
- text: s
173
- } : {
174
- buffer: s.toString('base64')
175
- };
176
- const processError = error => {
177
- const message = error.message || error.value || '';
178
- const stack = error.stack;
179
- if (!stack && !error.location) return {
180
- message
181
- };
182
- const tokens = [];
183
- const parsedStack = stack ? constructErrorStack(stack) : undefined;
184
- tokens.push((parsedStack === null || parsedStack === void 0 ? void 0 : parsedStack.message) || message);
185
- if (error.snippet) {
186
- tokens.push('');
187
- tokens.push(error.snippet);
188
- }
189
- if (parsedStack && parsedStack.stackLines.length) {
190
- const dimmedStackLines = parsedStack.stackLines.split('\n').map(line => dimify(line));
191
- tokens.push(dimmedStackLines.join('\n'));
192
- }
193
- let location = error.location;
194
- if (parsedStack && !location) location = parsedStack.location;
195
- if (error.cause) tokens.push(dimify('[cause]: ') + processError(error.cause).message);
196
- return {
197
- location,
198
- message: tokens.join('\n')
199
- };
200
- };
201
- const constructErrorStack = stack => parseErrorStack(stack, _path.default.sep, false);
202
- const dimify = text => `\x1b[2m${text}\x1b[22m`;
203
- const parseErrorStack = (stack, pathSeparator, showInternalStackFrames = false) => {
204
- const lines = stack.split("\n");
205
- let firstStackLineIndex = lines.findIndex(line => line.startsWith(" at "));
206
- if (firstStackLineIndex === -1) firstStackLineIndex = lines.length;
207
- const message = lines.slice(0, firstStackLineIndex).join("\n");
208
- const stackStartIndex = indexLocator(stack, '\n', firstStackLineIndex) + 1 || 0;
209
- const stackLinesString = stackStartIndex ? stack.slice(stackStartIndex) : '';
210
- let location;
211
- const stackLinesArr = stackLinesString.split('\n');
212
- for (const line of stackLinesArr) {
213
- const frame = parseStackFrame(line, pathSeparator, showInternalStackFrames);
214
- if (!frame || !frame.file) continue;
215
- if (isInNodeModules(frame.file, pathSeparator)) continue;
216
- location = {
217
- file: frame.file,
218
- column: frame.column || 0,
219
- line: frame.line || 0
220
- };
221
- break;
222
- }
223
- return {
224
- message,
225
- stackLines: stackLinesString,
226
- location
227
- };
228
- };
229
- const indexLocator = (str, pat, n) => {
230
- let L = str.length,
231
- i = -1;
232
- while (n-- && i++ < L) {
233
- i = str.indexOf(pat, i);
234
- if (i < 0) break;
235
- }
236
- return i;
237
- };
238
- const isInNodeModules = (file, pathSeparator) => file.includes(`${pathSeparator}node_modules${pathSeparator}`);
239
- const parseStackFrame = (text, pathSeparator, showInternalStackFrames) => {
240
- const re = new RegExp("^(?:\\s*at )?(?:(new) )?(?:(.*?) \\()?(?:eval at ([^ ]+) \\((.+?):(\\d+):(\\d+)\\), )?(?:(.+?):(\\d+):(\\d+)|(native))(\\)?)$");
241
- const methodRe = /^(.*?) \[as (.*?)\]$/;
242
- const match = text && text.match(re);
243
- if (!match) return null;
244
- let fname = match[2];
245
- let file = match[7];
246
- if (!file) return null;
247
- if (!showInternalStackFrames && (file.startsWith("internal") || file.startsWith("node:"))) return null;
248
- const line = match[8];
249
- const column = match[9];
250
- const closeParen = match[11] === ")";
251
- const frame = {
252
- file: "",
253
- line: 0,
254
- column: 0
255
- };
256
- if (line) frame.line = Number(line);
257
- if (column) frame.column = Number(column);
258
- if (closeParen && file) {
259
- let closes = 0;
260
- for (let i = file.length - 1; i > 0; i--) {
261
- if (file.charAt(i) === ")") {
262
- closes++;
263
- } else if (file.charAt(i) === "(" && file.charAt(i - 1) === " ") {
264
- closes--;
265
- if (closes === -1 && file.charAt(i - 1) === " ") {
266
- const before = file.slice(0, i - 1);
267
- const after = file.slice(i + 1);
268
- file = after;
269
- fname += ` (${before}`;
270
- break;
271
- }
272
- }
273
- }
274
- }
275
- if (fname) {
276
- const methodMatch = fname.match(methodRe);
277
- if (methodMatch) fname = methodMatch[1];
278
- }
279
- if (file) {
280
- if (file.startsWith("file://")) file = fileURLToPath(file, pathSeparator);
281
- frame.file = file;
282
- }
283
- if (fname) frame.function = fname;
284
- return frame;
285
- };
286
- const fileURLToPath = (fileUrl, pathSeparator) => {
287
- if (!fileUrl.startsWith("file://")) return fileUrl;
288
- let path = decodeURIComponent(fileUrl.slice(7));
289
- if (path.startsWith("/") && /^[a-zA-Z]:/.test(path.slice(1))) path = path.slice(1);
290
- return path.replace(/\//g, pathSeparator);
291
- };