@brillout/test-e2e 0.5.4 → 0.5.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/dist/getConfig.d.ts +0 -1
- package/dist/getConfig.js +0 -3
- package/dist/getCurrentTest.d.ts +3 -1
- package/dist/runAll.js +18 -20
- package/dist/setup.js +1 -1
- package/dist/utils/assert.js +1 -1
- package/package.json +1 -1
package/dist/getConfig.d.ts
CHANGED
package/dist/getConfig.js
CHANGED
|
@@ -30,9 +30,6 @@ function assertConfig(config) {
|
|
|
30
30
|
if (key === 'tolerateError') {
|
|
31
31
|
(0, utils_1.assertUsage)((0, utils_1.isCallable)(val), `${wrongType} function`);
|
|
32
32
|
}
|
|
33
|
-
else if (key === 'tolerateSkip') {
|
|
34
|
-
(0, utils_1.assertUsage)(typeof val === 'boolean', `${wrongType} boolean`);
|
|
35
|
-
}
|
|
36
33
|
else if (key === 'ci') {
|
|
37
34
|
// Only used by .github/workflows/ci/getTestJobs.mjs
|
|
38
35
|
// https://github.com/brillout/vite-plugin-ssr/blob/4fa329e4081655c39c4c70436ae73e563489439e/.github/workflows/ci/getTestJobs.mjs#L72
|
package/dist/getCurrentTest.d.ts
CHANGED
|
@@ -23,7 +23,9 @@ declare type TestInfo = {
|
|
|
23
23
|
isFlaky: boolean;
|
|
24
24
|
};
|
|
25
25
|
hasStartedRunning?: boolean;
|
|
26
|
-
skipped?:
|
|
26
|
+
skipped?: {
|
|
27
|
+
reason: string;
|
|
28
|
+
};
|
|
27
29
|
startServer?: () => Promise<void>;
|
|
28
30
|
terminateServer?: () => Promise<void>;
|
|
29
31
|
afterEach?: (hasFailed: boolean) => void;
|
package/dist/runAll.js
CHANGED
|
@@ -17,6 +17,18 @@ async function runAll(filter) {
|
|
|
17
17
|
await (0, getConfig_1.loadConfig)();
|
|
18
18
|
const testFiles = await (0, findTestFiles_1.findTestFiles)(filter);
|
|
19
19
|
const browser = await (0, getBrowser_1.getBrowser)();
|
|
20
|
+
const hasFailedTestFile = await runTestFiles(testFiles, browser);
|
|
21
|
+
await browser.close();
|
|
22
|
+
const hasFailLog = (0, logTestStatus_1.hasFail)();
|
|
23
|
+
if (hasFailedTestFile || hasFailLog) {
|
|
24
|
+
// hasFailedTestFile and hasFailLog are redundant
|
|
25
|
+
// - When assert.ts calls logFail() this code block isn't run
|
|
26
|
+
(0, utils_1.assert)(hasFailedTestFile && hasFailLog);
|
|
27
|
+
throw new Error('Following tests failed, see logs above for more information.');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.runAll = runAll;
|
|
31
|
+
async function runTestFiles(testFiles, browser) {
|
|
20
32
|
const failedFirstAttempt = [];
|
|
21
33
|
for (const testFile of testFiles) {
|
|
22
34
|
const success = await buildAndTest(testFile, browser, false);
|
|
@@ -24,6 +36,9 @@ async function runAll(filter) {
|
|
|
24
36
|
failedFirstAttempt.push(testFile);
|
|
25
37
|
}
|
|
26
38
|
}
|
|
39
|
+
if (!(0, utils_1.isCI)()) {
|
|
40
|
+
return failedFirstAttempt.length > 0;
|
|
41
|
+
}
|
|
27
42
|
const failedSecondAttempt = [];
|
|
28
43
|
for (const testFile of failedFirstAttempt) {
|
|
29
44
|
const success = await buildAndTest(testFile, browser, true);
|
|
@@ -31,17 +46,8 @@ async function runAll(filter) {
|
|
|
31
46
|
failedSecondAttempt.push(testFile);
|
|
32
47
|
}
|
|
33
48
|
}
|
|
34
|
-
|
|
35
|
-
const hasFailLog = (0, logTestStatus_1.hasFail)();
|
|
36
|
-
const hasFailedTestFile = failedSecondAttempt.length > 0;
|
|
37
|
-
if (hasFailedTestFile || hasFailLog) {
|
|
38
|
-
// hasFailedTestFile and hasFailLog are redundant
|
|
39
|
-
// - When assert.ts calls logFail() this code block isn't run
|
|
40
|
-
(0, utils_1.assert)(hasFailedTestFile && hasFailLog);
|
|
41
|
-
throw new Error('Following tests failed, see logs above for more information.');
|
|
42
|
-
}
|
|
49
|
+
return failedSecondAttempt.length > 0;
|
|
43
50
|
}
|
|
44
|
-
exports.runAll = runAll;
|
|
45
51
|
async function buildAndTest(testFile, browser, isSecondAttempt) {
|
|
46
52
|
(0, utils_1.assert)(testFile.endsWith('.ts'));
|
|
47
53
|
const testFileJs = testFile.replace('.ts', '.mjs');
|
|
@@ -63,7 +69,7 @@ async function runServerAndTests(browser, isSecondAttempt) {
|
|
|
63
69
|
// Set when user calls `skip()`
|
|
64
70
|
if (testInfo.skipped) {
|
|
65
71
|
assertSkipUsage(testInfo);
|
|
66
|
-
(0, logTestStatus_1.logWarn)(testInfo.skipped);
|
|
72
|
+
(0, logTestStatus_1.logWarn)(testInfo.skipped.reason);
|
|
67
73
|
return true;
|
|
68
74
|
}
|
|
69
75
|
// Set when user calls `run()`
|
|
@@ -191,6 +197,7 @@ function runTest(testFn, testFunctionTimeout) {
|
|
|
191
197
|
return promise;
|
|
192
198
|
}
|
|
193
199
|
function assertSkipUsage(testInfo) {
|
|
200
|
+
(0, utils_1.assert)(testInfo.skipped);
|
|
194
201
|
{
|
|
195
202
|
const err = 'You cannot call run() after calling skip()';
|
|
196
203
|
(0, utils_1.assertUsage)(testInfo.runInfo === undefined, err);
|
|
@@ -199,13 +206,4 @@ function assertSkipUsage(testInfo) {
|
|
|
199
206
|
const err = 'You cannot call test() after calling skip()';
|
|
200
207
|
(0, utils_1.assertUsage)(testInfo.tests === undefined, err);
|
|
201
208
|
}
|
|
202
|
-
const config = (0, getConfig_1.getConfig)();
|
|
203
|
-
{
|
|
204
|
-
const err = 'Using skip() while config tolerateSkip is set to false';
|
|
205
|
-
(0, utils_1.assertUsage)(config.tolerateSkip !== false, err);
|
|
206
|
-
}
|
|
207
|
-
{
|
|
208
|
-
const err = 'Using skip() while config tolerateSkip is set to undefined and tests are running in a parallel CI';
|
|
209
|
-
(0, utils_1.assertUsage)(!(config.tolerateSkip === undefined && (0, parallel_ci_1.isParallelCI)()), err);
|
|
210
|
-
}
|
|
211
209
|
}
|
package/dist/setup.js
CHANGED
|
@@ -31,7 +31,7 @@ const TIMEOUT_AUTORETRY = TIMEOUT_TEST_FUNCTION / 2;
|
|
|
31
31
|
const TIMEOUT_PLAYWRIGHT = TIMEOUT_TEST_FUNCTION / 2;
|
|
32
32
|
function skip(reason) {
|
|
33
33
|
const testInfo = (0, getCurrentTest_1.getCurrentTest)();
|
|
34
|
-
testInfo.skipped = reason;
|
|
34
|
+
testInfo.skipped = { reason };
|
|
35
35
|
}
|
|
36
36
|
exports.skip = skip;
|
|
37
37
|
function run(cmd, {
|
package/dist/utils/assert.js
CHANGED
|
@@ -81,7 +81,7 @@ function logDebugInfo() {
|
|
|
81
81
|
(0, logSection_1.logSection)('DEBUG INFO');
|
|
82
82
|
const testInfo = (0, getCurrentTest_1.getCurrentTest)();
|
|
83
83
|
console.log('testInfo.hasStartedRunning', testInfo.hasStartedRunning);
|
|
84
|
-
console.log('testInfo.skipped', testInfo.skipped);
|
|
84
|
+
console.log('testInfo.skipped?.reason', testInfo.skipped?.reason);
|
|
85
85
|
console.log('testInfo.runInfo', testInfo.runInfo);
|
|
86
86
|
console.log('testInfo.testFile', testInfo.testFile);
|
|
87
87
|
console.log('testInfo.testName', testInfo.testName);
|