@zohodesk/testinglibrary 3.1.5 → 3.1.6
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/build/core/playwright/helpers/auth/accountLogin.js +4 -1
- package/build/core/playwright/readConfigFile.js +0 -2
- package/build/core/playwright/setup/config-creator.js +2 -2
- package/build/core/playwright/setup/qc-custom-reporter.js +162 -0
- package/build/utils/fileUtils.js +2 -1
- package/npm-shrinkwrap.json +10810 -0
- package/package.json +2 -1
- package/unit_reports/unit-report.html +0 -260
|
@@ -13,6 +13,9 @@ async function accountLogin(page, useremail, password) {
|
|
|
13
13
|
await page.locator('#nextbtn').click();
|
|
14
14
|
const domainUrlOrigin = (0, _getUrlOrigin.default)(process.env.domain);
|
|
15
15
|
await page.waitForNavigation();
|
|
16
|
-
|
|
16
|
+
if (!page.url().includes(domainUrlOrigin)) {
|
|
17
|
+
await page.goto(domainUrlOrigin);
|
|
18
|
+
}
|
|
19
|
+
await page.waitForURL(`${domainUrlOrigin}/**`);
|
|
17
20
|
}
|
|
18
21
|
var _default = exports.default = accountLogin;
|
|
@@ -120,9 +120,7 @@ function generateConfigFromFile() {
|
|
|
120
120
|
const appConfig = new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)());
|
|
121
121
|
const userArgConfig = new _Configuration.default(_UserArgs.default.parseToObject(process.argv.slice(2)));
|
|
122
122
|
// overriding the user config's from CLI
|
|
123
|
-
//console.log('User Args Config:', userArgConfig.getAll());
|
|
124
123
|
uatConfig.addAll(appConfig);
|
|
125
|
-
//console.log('Application Config:', appConfig.getAll());
|
|
126
124
|
uatConfig.addAll(userArgConfig);
|
|
127
125
|
cachedConfig = uatConfig.getAll();
|
|
128
126
|
}
|
|
@@ -50,8 +50,8 @@ let reporter = [['html', {
|
|
|
50
50
|
outputFolder: reportPath,
|
|
51
51
|
open: openReportOn
|
|
52
52
|
}], ['list'], ['json', {
|
|
53
|
-
outputFile: _path.default.join(process.cwd(), 'uat', 'test-results', 'test-results.json')
|
|
54
|
-
}], ['./custom-reporter.js']];
|
|
53
|
+
outputFile: _path.default.join(process.cwd(), 'uat', 'json-test-results', 'test-results.json')
|
|
54
|
+
}], ['./custom-reporter.js'], ['./qc-custom-reporter.js']];
|
|
55
55
|
if (customReporter) {
|
|
56
56
|
reporter = [customReporter, ...reporter];
|
|
57
57
|
}
|
|
@@ -0,0 +1,162 @@
|
|
|
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,
|
|
36
|
+
stdout: result.stdout,
|
|
37
|
+
workerIndex: result.workerIndex,
|
|
38
|
+
duration: result.duration,
|
|
39
|
+
errors: ((_result$errors = result.errors) === null || _result$errors === void 0 ? void 0 : _result$errors.map(({
|
|
40
|
+
message,
|
|
41
|
+
stack,
|
|
42
|
+
snippet
|
|
43
|
+
}) => ({
|
|
44
|
+
message,
|
|
45
|
+
stack,
|
|
46
|
+
snippet
|
|
47
|
+
}))) ?? [],
|
|
48
|
+
steps: ((_result$steps = result.steps) === null || _result$steps === void 0 ? void 0 : _result$steps.map(step => extractMergedSteps(this.report.config.rootDir, step))) ?? []
|
|
49
|
+
};
|
|
50
|
+
const existingResults = this.testResultsById.get(key) ?? [];
|
|
51
|
+
this.testResultsById.set(key, [...existingResults, testResult]);
|
|
52
|
+
}
|
|
53
|
+
onEnd() {
|
|
54
|
+
var _this$rootSuite;
|
|
55
|
+
(_this$rootSuite = this.rootSuite) === null || _this$rootSuite === void 0 || (_this$rootSuite = _this$rootSuite.suites) === null || _this$rootSuite === void 0 || _this$rootSuite.map(suite => {
|
|
56
|
+
const extracted = suite.suites.map(suite => extractMergedSuite(this.report.config.rootDir, suite, this.testResultsById));
|
|
57
|
+
this.report.suites.push(...extracted);
|
|
58
|
+
});
|
|
59
|
+
_fs.default.writeFileSync(this.outputFile, JSON.stringify(this.report, null, 2));
|
|
60
|
+
console.log(`Custom JSON report written to: ${this.outputFile}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.default = CustomJsonReporter;
|
|
64
|
+
const extractMergedSuite = (rootDir, suite, testResultsById) => {
|
|
65
|
+
var _suite$suites;
|
|
66
|
+
const specMap = new Map();
|
|
67
|
+
for (const test of suite.tests ?? []) {
|
|
68
|
+
const existingSpec = specMap.get(test.title);
|
|
69
|
+
if (existingSpec) {
|
|
70
|
+
const newTestInfo = extractTestDetails(test, testResultsById);
|
|
71
|
+
existingSpec.tests.push(newTestInfo);
|
|
72
|
+
} else {
|
|
73
|
+
const newSpec = createSpecEntry(rootDir, test, testResultsById);
|
|
74
|
+
specMap.set(test.title, newSpec);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
title: suite.title,
|
|
79
|
+
...parseLocation(rootDir, suite.location),
|
|
80
|
+
...(suite.location && {
|
|
81
|
+
snippet: formSnippet(rootDir, suite.location)
|
|
82
|
+
}),
|
|
83
|
+
...(((_suite$suites = suite.suites) === null || _suite$suites === void 0 ? void 0 : _suite$suites.length) > 0 && {
|
|
84
|
+
suites: suite.suites.map(child => extractMergedSuite(rootDir, child, testResultsById))
|
|
85
|
+
}),
|
|
86
|
+
...(specMap.size > 0 && {
|
|
87
|
+
specs: Array.from(specMap.values())
|
|
88
|
+
})
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
const createSpecEntry = (rootDir, test, testResultsById) => ({
|
|
92
|
+
title: test.title,
|
|
93
|
+
...parseLocation(rootDir, test.location),
|
|
94
|
+
...(test.location && {
|
|
95
|
+
snippet: formSnippet(test.location)
|
|
96
|
+
}),
|
|
97
|
+
tests: [extractTestDetails(test, testResultsById)]
|
|
98
|
+
});
|
|
99
|
+
const extractTestDetails = (test, testResultsById) => {
|
|
100
|
+
var _test$location, _test$location2;
|
|
101
|
+
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}`;
|
|
102
|
+
return {
|
|
103
|
+
annotations: test.annotations,
|
|
104
|
+
expectedStatus: test.expectedStatus,
|
|
105
|
+
timeout: test.timeout,
|
|
106
|
+
retries: test.retries,
|
|
107
|
+
tags: test.tags,
|
|
108
|
+
results: testResultsById.get(key) ?? [],
|
|
109
|
+
status: test.outcome()
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
const extractMergedSteps = (rootDir, step) => ({
|
|
113
|
+
title: step.title,
|
|
114
|
+
duration: step.duration,
|
|
115
|
+
...(step.error && {
|
|
116
|
+
error: {
|
|
117
|
+
message: step.error.message,
|
|
118
|
+
stack: step.error.stack,
|
|
119
|
+
snippet: step.error.snippet
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
...parseLocation(rootDir, step.location),
|
|
123
|
+
status: step.status,
|
|
124
|
+
...(step.location && {
|
|
125
|
+
snippet: formSnippet(rootDir, step.location)
|
|
126
|
+
}),
|
|
127
|
+
...(step.steps && step.steps.length > 0 && {
|
|
128
|
+
steps: step.steps.map(subStep => extractMergedSteps(rootDir, subStep))
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
const formSnippet = (rootDir, location) => {
|
|
132
|
+
if (location && !(location !== null && location !== void 0 && location.file)) return '';
|
|
133
|
+
try {
|
|
134
|
+
const {
|
|
135
|
+
file,
|
|
136
|
+
line,
|
|
137
|
+
column
|
|
138
|
+
} = parseLocation(rootDir, location, false);
|
|
139
|
+
const raw = _fs.default.readFileSync(file, 'utf8');
|
|
140
|
+
return (0, _codeFrame.codeFrameColumns)(raw, {
|
|
141
|
+
start: {
|
|
142
|
+
line,
|
|
143
|
+
column
|
|
144
|
+
}
|
|
145
|
+
}, {
|
|
146
|
+
linesAbove: 2,
|
|
147
|
+
linesBelow: 2,
|
|
148
|
+
highlightCode: true
|
|
149
|
+
});
|
|
150
|
+
} catch {
|
|
151
|
+
return '';
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const parseLocation = (rootDir, {
|
|
155
|
+
file,
|
|
156
|
+
line,
|
|
157
|
+
column
|
|
158
|
+
} = {}, isRelative = true) => file ? {
|
|
159
|
+
file: isRelative ? _path.default.relative(rootDir, file) : file,
|
|
160
|
+
line,
|
|
161
|
+
column
|
|
162
|
+
} : {};
|
package/build/utils/fileUtils.js
CHANGED
|
@@ -14,7 +14,8 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
|
14
14
|
var _path = _interopRequireDefault(require("path"));
|
|
15
15
|
var _logger = require("./logger");
|
|
16
16
|
var glob = _interopRequireWildcard(require("glob"));
|
|
17
|
-
function
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
19
|
function checkIfFileExists(file) {
|
|
19
20
|
try {
|
|
20
21
|
_fs.default.accessSync(file, _fs.default.constants.F_OK);
|