@zohodesk/testinglibrary 0.0.59-n20-experimental → 0.0.61-n20-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/build/core/playwright/constants/reporterConstants.js +1 -0
- package/build/core/playwright/readConfigFile.js +1 -3
- package/build/core/playwright/reporter/PlaywrightReporter.js +44 -0
- package/build/core/playwright/reporter/UnitReporter.js +27 -0
- package/build/core/playwright/runner/SpawnRunner.js +1 -1
- package/build/core/playwright/setup/custom-reporter.js +1 -72
- package/build/lib/cli.js +30 -7
- package/build/utils/commonUtils.js +9 -0
- package/npm-shrinkwrap.json +7785 -3350
- package/package.json +15 -11
- package/build/core/playwright/report-generator.js +0 -42
|
@@ -11,5 +11,6 @@ const stage = (0, _ConfigurationHelper.getRunStage)();
|
|
|
11
11
|
class ReporterConstants {
|
|
12
12
|
static DEFAULT_REPORTER_PATH = `${_configConstants.default.TEST_SLICE_FOLDER}/${stage}/test-results/playwright-test-results.json`;
|
|
13
13
|
static LAST_RUN_REPORTER_PATH = `${_configConstants.default.TEST_SLICE_FOLDER}/${stage}/test-results/.last-run.json`;
|
|
14
|
+
static DEFAULT_UNIT_TEST_REPORTER_PATH = `${_configConstants.default.TEST_SLICE_FOLDER}/unit-test/unit_reports/report.html`;
|
|
14
15
|
}
|
|
15
16
|
exports.default = ReporterConstants;
|
|
@@ -55,8 +55,7 @@ function getDefaultConfig() {
|
|
|
55
55
|
featureFilesFolder: 'feature-files',
|
|
56
56
|
stepDefinitionsFolder: 'steps',
|
|
57
57
|
testSetup: {},
|
|
58
|
-
editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise']
|
|
59
|
-
showCaseTimings: true
|
|
58
|
+
editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise']
|
|
60
59
|
};
|
|
61
60
|
}
|
|
62
61
|
function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
@@ -114,7 +113,6 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
114
113
|
* @property {string} testIdAttribute: Change the default data-testid attribute. configure what attribute to search while calling getByTestId
|
|
115
114
|
* @property {Array} editionOrder: Order in the form of larger editions in the back. Edition with the most privelages should be last
|
|
116
115
|
* @property {testSetupConfig} testSetup: Specify page and context functions that will be called while intilaizing fixtures.
|
|
117
|
-
* @property {boolean} showCaseTimings: When true, the console reporter prints per-case start/end wall-clock times (h:mm:ss AM/PM) and a case-timings.json sidecar is written to reportPath for the HTML report addon. Default: true.
|
|
118
116
|
*/
|
|
119
117
|
|
|
120
118
|
/**
|
|
@@ -0,0 +1,44 @@
|
|
|
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 _child_process = require("child_process");
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _logger = require("../../../utils/logger");
|
|
11
|
+
var _rootPath = require("../../../utils/rootPath");
|
|
12
|
+
var _readConfigFile = require("../readConfigFile");
|
|
13
|
+
class PlaywrightReporter {
|
|
14
|
+
static generate() {
|
|
15
|
+
const userArgs = process.argv.slice(3);
|
|
16
|
+
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
17
|
+
const command = playwrightPath;
|
|
18
|
+
const {
|
|
19
|
+
reportPath: htmlPath
|
|
20
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
21
|
+
const args = ['show-report', htmlPath].concat(userArgs);
|
|
22
|
+
const childProcess = (0, _child_process.spawn)(command, args, {
|
|
23
|
+
stdio: 'inherit'
|
|
24
|
+
});
|
|
25
|
+
childProcess.on('error', error => {
|
|
26
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error);
|
|
27
|
+
});
|
|
28
|
+
childProcess.on('exit', (code, signal) => {
|
|
29
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
30
|
+
process.exit();
|
|
31
|
+
});
|
|
32
|
+
process.on('exit', () => {
|
|
33
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Terminating Playwright Process...');
|
|
34
|
+
childProcess.kill();
|
|
35
|
+
return;
|
|
36
|
+
});
|
|
37
|
+
process.on('SIGINT', () => {
|
|
38
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Cleaning up...');
|
|
39
|
+
childProcess.kill();
|
|
40
|
+
process.exit();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.default = PlaywrightReporter;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 _child_process = require("child_process");
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _os = require("os");
|
|
11
|
+
var _logger = require("../../../utils/logger");
|
|
12
|
+
var _reporterConstants = _interopRequireDefault(require("../constants/reporterConstants"));
|
|
13
|
+
class UnitReporter {
|
|
14
|
+
static generate() {
|
|
15
|
+
const reportPath = _path.default.resolve(process.cwd(), _reporterConstants.default.DEFAULT_UNIT_TEST_REPORTER_PATH);
|
|
16
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `Opening unit test report: ${reportPath}`);
|
|
17
|
+
const os = (0, _os.platform)();
|
|
18
|
+
const openCommand = os === 'darwin' ? 'open' : os === 'win32' ? 'start' : 'xdg-open';
|
|
19
|
+
(0, _child_process.execFile)(openCommand, [reportPath], error => {
|
|
20
|
+
if (error) {
|
|
21
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Failed to open report: ${error.message}`);
|
|
22
|
+
}
|
|
23
|
+
process.exit();
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = UnitReporter;
|
|
@@ -12,22 +12,6 @@ var _readConfigFile = require("../readConfigFile");
|
|
|
12
12
|
var _logger = require("../../../utils/logger");
|
|
13
13
|
var _configFileNameProvider = require("../helpers/configFileNameProvider");
|
|
14
14
|
var _mergeAbortedTests = _interopRequireDefault(require("../reporter/helpers/mergeAbortedTests"));
|
|
15
|
-
function formatTime(date) {
|
|
16
|
-
return date.toLocaleTimeString('en-US', {
|
|
17
|
-
hour: 'numeric',
|
|
18
|
-
minute: '2-digit',
|
|
19
|
-
second: '2-digit',
|
|
20
|
-
hour12: true
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
function formatDuration(ms) {
|
|
24
|
-
if (ms < 1000) return `${ms}ms`;
|
|
25
|
-
const totalSeconds = ms / 1000;
|
|
26
|
-
if (totalSeconds < 60) return `${totalSeconds.toFixed(2)}s`;
|
|
27
|
-
const minutes = Math.floor(totalSeconds / 60);
|
|
28
|
-
const seconds = (totalSeconds - minutes * 60).toFixed(2);
|
|
29
|
-
return `${minutes}m ${seconds}s`;
|
|
30
|
-
}
|
|
31
15
|
class JSONSummaryReporter {
|
|
32
16
|
constructor() {
|
|
33
17
|
this.durationInMS = -1;
|
|
@@ -42,22 +26,11 @@ class JSONSummaryReporter {
|
|
|
42
26
|
this.failedSteps = [];
|
|
43
27
|
this.status = 'unknown';
|
|
44
28
|
this.startedAt = 0;
|
|
45
|
-
|
|
46
|
-
this._open = config.openReportOn;
|
|
47
|
-
this._showCaseTimings = config.showCaseTimings !== false;
|
|
48
|
-
this._caseTimings = [];
|
|
29
|
+
this._open = (0, _readConfigFile.generateConfigFromFile)().openReportOn;
|
|
49
30
|
}
|
|
50
31
|
onBegin() {
|
|
51
32
|
this.startedAt = Date.now();
|
|
52
33
|
}
|
|
53
|
-
onTestBegin(test) {
|
|
54
|
-
if (!this._showCaseTimings) return;
|
|
55
|
-
const {
|
|
56
|
-
fullTitle
|
|
57
|
-
} = this.getTitle(test);
|
|
58
|
-
const startedAtLabel = formatTime(new Date());
|
|
59
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, `▶ ${fullTitle} — started at ${startedAtLabel}`);
|
|
60
|
-
}
|
|
61
34
|
getTitle(test) {
|
|
62
35
|
const title = [];
|
|
63
36
|
const fileName = [];
|
|
@@ -103,40 +76,6 @@ class JSONSummaryReporter {
|
|
|
103
76
|
this[status].push(fileName);
|
|
104
77
|
}
|
|
105
78
|
this[status].push(fileName);
|
|
106
|
-
if (this._showCaseTimings && result.startTime) {
|
|
107
|
-
const startDate = new Date(result.startTime);
|
|
108
|
-
const endDate = new Date(startDate.getTime() + (result.duration || 0));
|
|
109
|
-
const startLabel = formatTime(startDate);
|
|
110
|
-
const endLabel = formatTime(endDate);
|
|
111
|
-
const durationLabel = formatDuration(result.duration || 0);
|
|
112
|
-
const statusGlyph = result.status === 'passed' ? '✓' : result.status === 'skipped' ? '○' : '✗';
|
|
113
|
-
const logType = result.status === 'passed' ? _logger.Logger.SUCCESS_TYPE : result.status === 'skipped' ? _logger.Logger.INFO_TYPE : _logger.Logger.FAILURE_TYPE;
|
|
114
|
-
_logger.Logger.log(logType, `${statusGlyph} ${fullTitle} — ended at ${endLabel} (started ${startLabel}, took ${durationLabel})`);
|
|
115
|
-
const isFailure = result.status !== 'passed' && result.status !== 'skipped';
|
|
116
|
-
if (isFailure) {
|
|
117
|
-
var _result$error;
|
|
118
|
-
this._caseTimings.push({
|
|
119
|
-
title: fullTitle,
|
|
120
|
-
fileName,
|
|
121
|
-
status: result.status,
|
|
122
|
-
retry: result.retry,
|
|
123
|
-
startTime: startDate.toISOString(),
|
|
124
|
-
endTime: endDate.toISOString(),
|
|
125
|
-
startTimeFormatted: startLabel,
|
|
126
|
-
endTimeFormatted: endLabel,
|
|
127
|
-
duration: result.duration || 0,
|
|
128
|
-
durationFormatted: durationLabel,
|
|
129
|
-
errorMessage: (_result$error = result.error) === null || _result$error === void 0 ? void 0 : _result$error.message,
|
|
130
|
-
failedSteps: (result.steps || []).filter(step => step.error).map(step => {
|
|
131
|
-
var _step$error;
|
|
132
|
-
return {
|
|
133
|
-
title: step.title,
|
|
134
|
-
error: (_step$error = step.error) === null || _step$error === void 0 ? void 0 : _step$error.message
|
|
135
|
-
};
|
|
136
|
-
})
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
79
|
}
|
|
141
80
|
onError(error) {
|
|
142
81
|
this.errored.push({
|
|
@@ -183,16 +122,6 @@ class JSONSummaryReporter {
|
|
|
183
122
|
reportPath
|
|
184
123
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
185
124
|
(0, _fileUtils.writeFileContents)(_path.default.join(reportPath, './', (0, _configFileNameProvider.getReportFileName)()), JSON.stringify(this, null, ' '));
|
|
186
|
-
if (this._showCaseTimings && this._caseTimings.length > 0) {
|
|
187
|
-
const timingsPayload = {
|
|
188
|
-
suiteStartedAt: new Date(this.startedAt).toISOString(),
|
|
189
|
-
suiteEndedAt: new Date(this.startedAt + this.durationInMS).toISOString(),
|
|
190
|
-
suiteDurationMs: this.durationInMS,
|
|
191
|
-
failedCount: this._caseTimings.length,
|
|
192
|
-
cases: this._caseTimings
|
|
193
|
-
};
|
|
194
|
-
(0, _fileUtils.writeFileContents)(_path.default.join(reportPath, 'case-timings.json'), JSON.stringify(timingsPayload, null, ' '));
|
|
195
|
-
}
|
|
196
125
|
}
|
|
197
126
|
onExit() {
|
|
198
127
|
// Update .last-run.json with aborted tests due to timing out or interruption
|
package/build/lib/cli.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
var _testRunner = _interopRequireDefault(require("../core/playwright/test-runner"));
|
|
5
|
-
var
|
|
5
|
+
var _unitTestingFramework = require("@zohodesk/unit-testing-framework");
|
|
6
|
+
var _PlaywrightReporter = _interopRequireDefault(require("../core/playwright/reporter/PlaywrightReporter"));
|
|
7
|
+
var _UnitReporter = _interopRequireDefault(require("../core/playwright/reporter/UnitReporter"));
|
|
6
8
|
var _codegen = _interopRequireDefault(require("../core/playwright/codegen"));
|
|
7
9
|
var _logger = require("../utils/logger");
|
|
8
10
|
var _setupProject = _interopRequireDefault(require("../setup-folder-structure/setupProject"));
|
|
@@ -11,15 +13,25 @@ var _clearCaches = _interopRequireDefault(require("../core/playwright/clear-cach
|
|
|
11
13
|
var _helper = _interopRequireDefault(require("../setup-folder-structure/helper"));
|
|
12
14
|
var _parseUserArgs = _interopRequireDefault(require("../core/playwright/helpers/parseUserArgs"));
|
|
13
15
|
var _validateFeature = _interopRequireDefault(require("../core/playwright/validateFeature"));
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
var _commonUtils = require("../utils/commonUtils");
|
|
16
17
|
const [,, option, ...otherOptions] = process.argv;
|
|
17
18
|
switch (option) {
|
|
18
19
|
case 'test':
|
|
19
20
|
{
|
|
20
21
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Running Tests..');
|
|
21
22
|
(0, _testRunner.default)();
|
|
22
|
-
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
case 'unit-test':
|
|
26
|
+
{
|
|
27
|
+
const testFile = process.argv[3];
|
|
28
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Running Unit Tests..');
|
|
29
|
+
const options = {};
|
|
30
|
+
if (testFile) {
|
|
31
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Filtering tests with pattern: ${testFile}`);
|
|
32
|
+
options.testPathPattern = testFile;
|
|
33
|
+
}
|
|
34
|
+
(0, _unitTestingFramework.createJestRunner)(options);
|
|
23
35
|
break;
|
|
24
36
|
}
|
|
25
37
|
case 'validate':
|
|
@@ -40,9 +52,14 @@ switch (option) {
|
|
|
40
52
|
}
|
|
41
53
|
case 'report':
|
|
42
54
|
{
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
55
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Generating UAT Reports...');
|
|
56
|
+
_PlaywrightReporter.default.generate();
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case 'ut-report':
|
|
60
|
+
{
|
|
61
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Generating Unit Test Reports...');
|
|
62
|
+
_UnitReporter.default.generate();
|
|
46
63
|
break;
|
|
47
64
|
}
|
|
48
65
|
case 'codegen':
|
|
@@ -69,6 +86,12 @@ switch (option) {
|
|
|
69
86
|
(0, _clearCaches.default)();
|
|
70
87
|
break;
|
|
71
88
|
}
|
|
89
|
+
case 'stepsGenerator':
|
|
90
|
+
{
|
|
91
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Created agents and prompts md files under .github folder...');
|
|
92
|
+
(0, _commonUtils.copyGithubFolder)();
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
72
95
|
case 'help':
|
|
73
96
|
default:
|
|
74
97
|
{
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.copyCommonSpecs = copyCommonSpecs;
|
|
8
|
+
exports.copyGithubFolder = copyGithubFolder;
|
|
8
9
|
var _fileUtils = require("./fileUtils");
|
|
9
10
|
var _path = _interopRequireDefault(require("path"));
|
|
10
11
|
var _configConstants = _interopRequireDefault(require("../core/playwright/constants/configConstants"));
|
|
@@ -17,4 +18,12 @@ function copyCommonSpecs() {
|
|
|
17
18
|
const destDirectory = _path.default.resolve(process.cwd(), _configConstants.default.TEST_SLICE_FOLDER, stage, 'modules', '.testingLib-common');
|
|
18
19
|
(0, _fileUtils.deleteFolder)(destDirectory);
|
|
19
20
|
(0, _fileUtils.copyDirectory)(commonSpecPath, destDirectory);
|
|
21
|
+
}
|
|
22
|
+
function copyGithubFolder() {
|
|
23
|
+
const libraryPath = require.resolve("@zohodesk/testinglibrary");
|
|
24
|
+
// libraryPath will be build/index.js, go two levels up to reach the package root where .github lives
|
|
25
|
+
const githubSrcPath = _path.default.resolve(libraryPath, '../../', '.github');
|
|
26
|
+
const destDirectory = _path.default.resolve(process.cwd(), '../../', '.github');
|
|
27
|
+
(0, _fileUtils.deleteFolder)(destDirectory);
|
|
28
|
+
(0, _fileUtils.copyDirectory)(githubSrcPath, destDirectory);
|
|
20
29
|
}
|