@brillout/test-e2e 0.5.19 → 0.5.21
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/dist/runAll.js +28 -20
- package/package.json +2 -2
package/dist/runAll.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.runAll = void 0;
|
|
4
7
|
const getCurrentTest_1 = require("./getCurrentTest");
|
|
@@ -12,6 +15,7 @@ const findTestFiles_1 = require("./findTestFiles");
|
|
|
12
15
|
const getConfig_1 = require("./getConfig");
|
|
13
16
|
const logError_1 = require("./logError");
|
|
14
17
|
const logTestStatus_1 = require("./logTestStatus");
|
|
18
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
15
19
|
async function runAll(filter) {
|
|
16
20
|
await (0, getConfig_1.loadConfig)();
|
|
17
21
|
const testFiles = await (0, findTestFiles_1.findTestFiles)(filter);
|
|
@@ -25,10 +29,10 @@ async function runAll(filter) {
|
|
|
25
29
|
// - When assert.ts calls logFail() this code block isn't run
|
|
26
30
|
(0, utils_1.assert)(hasFailedTestFile && hasFailLog);
|
|
27
31
|
(0, utils_1.assert)(failedTestFiles.length > 0);
|
|
28
|
-
throw new Error([
|
|
29
|
-
'Following test files failed, see logs above for more information (search for [TEST_FAILURE])
|
|
32
|
+
throw new Error(picocolors_1.default.red(picocolors_1.default.bold([
|
|
33
|
+
'Following test files failed, see logs above for more information (search for [TEST_FAILURE]):',
|
|
30
34
|
...failedTestFiles.map((testFile) => ` ${testFile}`),
|
|
31
|
-
].join('\n'));
|
|
35
|
+
].join('\n'))));
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
exports.runAll = runAll;
|
|
@@ -37,10 +41,10 @@ async function runTestFiles(testFiles, browser) {
|
|
|
37
41
|
let failedTestFiles = [];
|
|
38
42
|
let doNotRetry = false;
|
|
39
43
|
for (const testFile of testFiles) {
|
|
40
|
-
const success = await buildAndTest(testFile, browser, false);
|
|
44
|
+
const { success, isFlaky } = await buildAndTest(testFile, browser, false);
|
|
41
45
|
if (!success) {
|
|
42
46
|
failedTestFiles.push(testFile);
|
|
43
|
-
if (!isFlaky
|
|
47
|
+
if (!isFlaky) {
|
|
44
48
|
doNotRetry = true;
|
|
45
49
|
}
|
|
46
50
|
if (utils_1.cliOptions.bail) {
|
|
@@ -57,9 +61,9 @@ async function runTestFiles(testFiles, browser) {
|
|
|
57
61
|
else {
|
|
58
62
|
// Second & third attempt
|
|
59
63
|
for (let i = 0; i <= 1; i++) {
|
|
60
|
-
console.log((i === 0 ? 'SECOND' : 'THIRD') + '_ATTEMPT');
|
|
64
|
+
console.log('[' + (i === 0 ? 'SECOND' : 'THIRD') + '_ATTEMPT]');
|
|
61
65
|
for (const testFile of failedTestFiles) {
|
|
62
|
-
const success = await buildAndTest(testFile, browser, i === 1);
|
|
66
|
+
const { success } = await buildAndTest(testFile, browser, i === 1);
|
|
63
67
|
if (success) {
|
|
64
68
|
failedTestFiles = failedTestFiles.filter((t) => t !== testFile);
|
|
65
69
|
}
|
|
@@ -68,12 +72,6 @@ async function runTestFiles(testFiles, browser) {
|
|
|
68
72
|
return failedTestFiles;
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
|
-
function isFlaky() {
|
|
72
|
-
const testInfo = (0, getCurrentTest_1.getCurrentTest)();
|
|
73
|
-
// Set when user calls run()
|
|
74
|
-
(0, utils_1.assert)(testInfo.runInfo);
|
|
75
|
-
return testInfo.runInfo.isFlaky;
|
|
76
|
-
}
|
|
77
75
|
async function buildAndTest(testFile, browser, isThirdAttempt) {
|
|
78
76
|
(0, utils_1.assert)(testFile.endsWith('.ts'));
|
|
79
77
|
const testFileJs = testFile.replace('.ts', '.mjs');
|
|
@@ -95,35 +93,45 @@ async function buildAndTest(testFile, browser, isThirdAttempt) {
|
|
|
95
93
|
if (execErr) {
|
|
96
94
|
(0, logTestStatus_1.logFail)(`an error was thrown while executing the file ${testFile}`, true);
|
|
97
95
|
(0, logError_1.logError)(execErr);
|
|
98
|
-
return
|
|
96
|
+
return {
|
|
97
|
+
success: false,
|
|
98
|
+
isFlaky: false,
|
|
99
|
+
};
|
|
99
100
|
}
|
|
100
101
|
// When user calls skip()
|
|
101
102
|
const testInfo = (0, getCurrentTest_1.getCurrentTest)();
|
|
102
103
|
if (testInfo.skipped) {
|
|
103
104
|
assertSkipUsage(testInfo);
|
|
104
105
|
(0, logTestStatus_1.logWarn)(testInfo.skipped.reason);
|
|
105
|
-
return
|
|
106
|
+
return {
|
|
107
|
+
success: true,
|
|
108
|
+
isFlaky: false,
|
|
109
|
+
};
|
|
106
110
|
}
|
|
107
111
|
else {
|
|
108
112
|
// Set when user calls run() or runCommandThatTerminates()
|
|
109
113
|
(0, utils_1.assert)(testInfo.runInfo);
|
|
110
114
|
}
|
|
115
|
+
const { isFlaky } = testInfo.runInfo;
|
|
111
116
|
// When user calls run runCommandThatTerminates()
|
|
112
117
|
if (testInfo.runInfo.isRunCommandThatTerminates) {
|
|
113
118
|
(0, utils_1.assertUsage)(!testInfo.tests, "Can't call test() when calling runCommandThatTerminates()");
|
|
114
119
|
(0, utils_1.assertUsage)(!testInfo.startServer, "Can't call run() when calling runCommandThatTerminates()");
|
|
115
120
|
(0, logTestStatus_1.logPass)();
|
|
116
|
-
return
|
|
121
|
+
return {
|
|
122
|
+
success: true,
|
|
123
|
+
isFlaky,
|
|
124
|
+
};
|
|
117
125
|
}
|
|
118
|
-
const success = await runServerAndTests(browser, isThirdAttempt);
|
|
126
|
+
const success = await runServerAndTests(browser, isThirdAttempt, isFlaky);
|
|
119
127
|
(0, getCurrentTest_2.setCurrentTest)(null);
|
|
120
|
-
return success;
|
|
128
|
+
return { success, isFlaky };
|
|
121
129
|
}
|
|
122
|
-
async function runServerAndTests(browser, isThirdAttempt) {
|
|
130
|
+
async function runServerAndTests(browser, isThirdAttempt, isFlaky) {
|
|
123
131
|
const testInfo = (0, getCurrentTest_1.getCurrentTest)();
|
|
124
132
|
(0, utils_1.assert)(testInfo.startServer);
|
|
125
133
|
(0, utils_1.assert)(testInfo.terminateServer);
|
|
126
|
-
const isFinalAttempt = isThirdAttempt || !isFlaky
|
|
134
|
+
const isFinalAttempt = isThirdAttempt || !isFlaky;
|
|
127
135
|
const page = await browser.newPage();
|
|
128
136
|
testInfo.page = page;
|
|
129
137
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brillout/test-e2e",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.21",
|
|
4
4
|
"bin": "./bin.js",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"release": "npm version patch && npm publish && git push && git push --tags"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@brillout/part-regex": "^0.1.
|
|
16
|
+
"@brillout/part-regex": "^0.1.3",
|
|
17
17
|
"chai": "^4.3.6",
|
|
18
18
|
"esbuild": "^0.16.5",
|
|
19
19
|
"fast-glob": "^3.2.12",
|