@brillout/test-e2e 0.1.20 → 0.1.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/Logs.d.ts +1 -1
- package/dist/Logs.js +1 -1
- package/dist/runTests.js +8 -2
- package/dist/setup.js +10 -2
- package/package.json +1 -1
package/dist/Logs.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare type LogEntry = {
|
|
|
13
13
|
logTimestamp: string;
|
|
14
14
|
isNotFailure: boolean;
|
|
15
15
|
};
|
|
16
|
-
declare function hasError(onlyFailOnBrowserError
|
|
16
|
+
declare function hasError(onlyFailOnBrowserError?: boolean): boolean;
|
|
17
17
|
declare function clear(): void;
|
|
18
18
|
declare function flush(): void;
|
|
19
19
|
declare function add({ logSource, logText }: {
|
package/dist/Logs.js
CHANGED
|
@@ -17,7 +17,7 @@ const getCurrentTest_1 = require("./getCurrentTest");
|
|
|
17
17
|
const getConfig_1 = require("./getConfig");
|
|
18
18
|
let logEntries = [];
|
|
19
19
|
let logEntriesNotPrinted = [];
|
|
20
|
-
function hasError(onlyFailOnBrowserError) {
|
|
20
|
+
function hasError(onlyFailOnBrowserError = false) {
|
|
21
21
|
const logErrors = logEntries.filter(({ logSource, isNotFailure }) => {
|
|
22
22
|
if (isNotFailure) {
|
|
23
23
|
return;
|
package/dist/runTests.js
CHANGED
|
@@ -5,6 +5,7 @@ const getCurrentTest_1 = require("./getCurrentTest");
|
|
|
5
5
|
const Logs_1 = require("./Logs");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
7
|
const picocolors_1 = require("picocolors");
|
|
8
|
+
const logsContainError_errMsg = 'The browser/server threw/logged one or more error/warning, see logs below.';
|
|
8
9
|
async function runTests(browser) {
|
|
9
10
|
const testInfo = (0, getCurrentTest_1.getCurrentTest)();
|
|
10
11
|
if (utils_1.isTTY) {
|
|
@@ -60,7 +61,7 @@ async function runTests(browser) {
|
|
|
60
61
|
console.error(err);
|
|
61
62
|
}
|
|
62
63
|
if (hasErrorLog) {
|
|
63
|
-
console.log(new Error(
|
|
64
|
+
console.log(new Error(logsContainError_errMsg));
|
|
64
65
|
}
|
|
65
66
|
Logs_1.Logs.flush();
|
|
66
67
|
process.exit(1);
|
|
@@ -71,6 +72,11 @@ async function runTests(browser) {
|
|
|
71
72
|
}
|
|
72
73
|
await testInfo.terminateServer();
|
|
73
74
|
await page.close();
|
|
75
|
+
// Handle case that an error occured during `terminateServer()`
|
|
76
|
+
if (Logs_1.Logs.hasError()) {
|
|
77
|
+
console.log(new Error(logsContainError_errMsg));
|
|
78
|
+
Logs_1.Logs.flush();
|
|
79
|
+
}
|
|
74
80
|
logTestsResult(true);
|
|
75
81
|
}
|
|
76
82
|
exports.runTests = runTests;
|
|
@@ -110,7 +116,7 @@ function logTestsResult(success) {
|
|
|
110
116
|
return;
|
|
111
117
|
}
|
|
112
118
|
if (testInfo.skipped) {
|
|
113
|
-
console.log(`${skipStyle('
|
|
119
|
+
console.log(`${skipStyle('WARN')} ${testInfo.testFile} (${testInfo.skipped})`);
|
|
114
120
|
}
|
|
115
121
|
else {
|
|
116
122
|
console.log(`${failStyle('FAIL')} ${testInfo.testFile}`);
|
package/dist/setup.js
CHANGED
|
@@ -25,7 +25,7 @@ exports.urlBaseChange = urlBaseChange;
|
|
|
25
25
|
var editFile_2 = require("./editFile");
|
|
26
26
|
Object.defineProperty(exports, "editFile", { enumerable: true, get: function () { return editFile_2.editFile; } });
|
|
27
27
|
Object.defineProperty(exports, "editFileRevert", { enumerable: true, get: function () { return editFile_2.editFileRevert; } });
|
|
28
|
-
const TIMEOUT_NPM_SCRIPT =
|
|
28
|
+
const TIMEOUT_NPM_SCRIPT = 2 * 60 * 1000;
|
|
29
29
|
const TIMEOUT_TEST_FUNCTION = 60 * 1000 * (!isGithubAction() ? 1 : isWindows() ? 5 : 3);
|
|
30
30
|
const TIMEOUT_PROCESS_TERMINATION = 10 * 1000 * (!isGithubAction() ? 1 : isLinux() ? 1 : 4);
|
|
31
31
|
const TIMEOUT_AUTORETRY = TIMEOUT_TEST_FUNCTION / 2;
|
|
@@ -79,6 +79,10 @@ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect
|
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
testInfo.terminateServer = async () => {
|
|
82
|
+
Logs_1.Logs.add({
|
|
83
|
+
logSource: 'run()',
|
|
84
|
+
logText: 'Terminate server.',
|
|
85
|
+
});
|
|
82
86
|
page_1.page.off('console', onConsole);
|
|
83
87
|
page_1.page.off('pageerror', onPageError);
|
|
84
88
|
// `runProcess` is `undefined` if `start()` failed.
|
|
@@ -137,7 +141,7 @@ async function start() {
|
|
|
137
141
|
(0, utils_2.assert)(getRunInfo().cmd === cmd);
|
|
138
142
|
Logs_1.Logs.add({
|
|
139
143
|
logSource: 'run()',
|
|
140
|
-
logText: '
|
|
144
|
+
logText: 'Server is ready.',
|
|
141
145
|
});
|
|
142
146
|
hasSuccessfullyStarted = true;
|
|
143
147
|
clearTimeout(serverStartTimeout);
|
|
@@ -309,6 +313,8 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
|
|
|
309
313
|
await exitAndFail(new Error('Port conflict? Port already in use EADDRINUSE.'));
|
|
310
314
|
}
|
|
311
315
|
});
|
|
316
|
+
let exitPromiseResolve;
|
|
317
|
+
const exitPromise = new Promise((r) => (exitPromiseResolve = r));
|
|
312
318
|
proc.on('exit', (code) => {
|
|
313
319
|
procExited = true;
|
|
314
320
|
(0, utils_2.assert)(getRunInfo().cmd === cmd);
|
|
@@ -329,6 +335,7 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
|
|
|
329
335
|
logSource: 'run()',
|
|
330
336
|
});
|
|
331
337
|
}
|
|
338
|
+
exitPromiseResolve();
|
|
332
339
|
});
|
|
333
340
|
return { terminate, processHasExited };
|
|
334
341
|
function processHasExited() {
|
|
@@ -365,6 +372,7 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
|
|
|
365
372
|
});
|
|
366
373
|
}
|
|
367
374
|
clearTimeout(timeout);
|
|
375
|
+
await exitPromise;
|
|
368
376
|
resolve();
|
|
369
377
|
return promise;
|
|
370
378
|
}
|