@brillout/test-e2e 0.4.1 → 0.4.3
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/logSection.js +5 -4
- package/dist/runTests.js +5 -5
- package/dist/setup.js +32 -15
- package/package.json +1 -1
package/dist/logSection.js
CHANGED
|
@@ -6,9 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.logSection = void 0;
|
|
7
7
|
const picocolors_1 = __importDefault(require("picocolors"));
|
|
8
8
|
function logSection(sectionTitle) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
console.log();
|
|
12
|
-
console.log(picocolors_1.default.bold(
|
|
9
|
+
const title = `vvvvvv ${sectionTitle} vvvvvv`;
|
|
10
|
+
const width = title.length;
|
|
11
|
+
console.log(picocolors_1.default.bold('v'.repeat(width)));
|
|
12
|
+
console.log(picocolors_1.default.bold(title));
|
|
13
|
+
console.log(picocolors_1.default.bold('v'.repeat(width)));
|
|
13
14
|
}
|
|
14
15
|
exports.logSection = logSection;
|
package/dist/runTests.js
CHANGED
|
@@ -73,7 +73,6 @@ async function runTestFile(browser) {
|
|
|
73
73
|
await testInfo.startServer();
|
|
74
74
|
}
|
|
75
75
|
catch (err) {
|
|
76
|
-
logResult(false);
|
|
77
76
|
logFailureReason('an error occurred while starting the server');
|
|
78
77
|
logError(err);
|
|
79
78
|
Logs_1.Logs.flushLogs();
|
|
@@ -100,7 +99,6 @@ async function runTestFile(browser) {
|
|
|
100
99
|
const hasErrorLog = Logs_1.Logs.hasErrorLogs(failOnWarning);
|
|
101
100
|
const isFailure = err || hasErrorLog;
|
|
102
101
|
if (isFailure) {
|
|
103
|
-
logResult(false);
|
|
104
102
|
if (err) {
|
|
105
103
|
logFailureReason(`the test "${testDesc}" threw an error`);
|
|
106
104
|
logError(err);
|
|
@@ -123,7 +121,9 @@ async function runTestFile(browser) {
|
|
|
123
121
|
// Check whether stderr emitted during testInfo.terminateServer()
|
|
124
122
|
{
|
|
125
123
|
const failOnWarning = true;
|
|
126
|
-
if (Logs_1.Logs.hasErrorLogs(failOnWarning)
|
|
124
|
+
if (Logs_1.Logs.hasErrorLogs(failOnWarning) &&
|
|
125
|
+
// See comments about taskkill in src/setup.ts
|
|
126
|
+
!(0, utils_1.isWindows)()) {
|
|
127
127
|
logFailureReason(`${getErrorType(failOnWarning)} occurred during server termination`);
|
|
128
128
|
Logs_1.Logs.logErrors(failOnWarning);
|
|
129
129
|
Logs_1.Logs.flushLogs();
|
|
@@ -178,10 +178,10 @@ function logResult(success) {
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
function logFailureReason(reason) {
|
|
181
|
-
|
|
181
|
+
logResult(false);
|
|
182
182
|
const { FAIL } = getStatusTags();
|
|
183
183
|
const color = (s) => picocolors_1.default.red(picocolors_1.default.bold(s));
|
|
184
|
-
const msg = `Test ${
|
|
184
|
+
const msg = `Test ${FAIL} because ${reason}, see below.`;
|
|
185
185
|
console.log(color(msg));
|
|
186
186
|
}
|
|
187
187
|
function logError(err) {
|
package/dist/setup.js
CHANGED
|
@@ -26,7 +26,7 @@ Object.defineProperty(exports, "expectError", { enumerable: true, get: function
|
|
|
26
26
|
const serverUrlDefault = 'http://localhost:3000';
|
|
27
27
|
const TIMEOUT_NPM_SCRIPT = 2 * 60 * 1000 * (!(0, utils_1.isCI)() ? 1 : (0, utils_1.isWindows)() ? 2 : 1);
|
|
28
28
|
const TIMEOUT_TEST_FUNCTION = 60 * 1000 * (!(0, utils_1.isCI)() ? 1 : (0, utils_1.isWindows)() ? 5 : 3);
|
|
29
|
-
const TIMEOUT_PROCESS_TERMINATION = 10 * 1000 * (!(0, utils_1.isCI)() ? 1 : (0, utils_1.isWindows)() ?
|
|
29
|
+
const TIMEOUT_PROCESS_TERMINATION = 10 * 1000 * (!(0, utils_1.isCI)() ? 1 : (0, utils_1.isWindows)() ? 3 : !(0, utils_1.isLinux)() ? 3 : 1);
|
|
30
30
|
const TIMEOUT_AUTORETRY = TIMEOUT_TEST_FUNCTION / 2;
|
|
31
31
|
const TIMEOUT_PLAYWRIGHT = TIMEOUT_TEST_FUNCTION / 2;
|
|
32
32
|
function skip(reason) {
|
|
@@ -87,7 +87,7 @@ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect
|
|
|
87
87
|
page_1.page.off('pageerror', onPageError);
|
|
88
88
|
// `runProcess` is `undefined` if `start()` failed.
|
|
89
89
|
if (runProcess) {
|
|
90
|
-
await runProcess.terminate(
|
|
90
|
+
await runProcess.terminate();
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
return;
|
|
@@ -169,7 +169,7 @@ async function start() {
|
|
|
169
169
|
logSource: 'run() failure',
|
|
170
170
|
logText: errMsg,
|
|
171
171
|
});
|
|
172
|
-
await terminate();
|
|
172
|
+
await terminate(true);
|
|
173
173
|
rejectServerStart(new Error(errMsg));
|
|
174
174
|
}, timeoutTotal);
|
|
175
175
|
// Kill any process that listens to the server port
|
|
@@ -210,7 +210,7 @@ async function start() {
|
|
|
210
210
|
});
|
|
211
211
|
return promise;
|
|
212
212
|
}
|
|
213
|
-
function stopProcess({ proc, cwd, cmd,
|
|
213
|
+
function stopProcess({ proc, cwd, cmd, force, }) {
|
|
214
214
|
const prefix = `[Run Stop][${cwd}][${cmd}]`;
|
|
215
215
|
let resolve;
|
|
216
216
|
let reject;
|
|
@@ -231,16 +231,32 @@ function stopProcess({ proc, cwd, cmd, signal, }) {
|
|
|
231
231
|
if ((0, utils_1.isWindows)()) {
|
|
232
232
|
// - https://github.com/nodejs/node/issues/3617#issuecomment-377731194
|
|
233
233
|
// - https://stackoverflow.com/questions/23706055/why-can-i-not-kill-my-child-process-in-nodejs-on-windows/28163919#28163919
|
|
234
|
+
// - taskkill seems to be buggy in many ways:
|
|
235
|
+
// - taskkill seems to make the process exit with code `1`
|
|
236
|
+
// - Because process exits with code `1`, Node.js/npm complains:
|
|
237
|
+
// ```
|
|
238
|
+
// [15:36:10.626][\examples\react][npm run preview][stderr] npm
|
|
239
|
+
// [15:36:10.626][\examples\react][npm run preview][stderr]
|
|
240
|
+
// [15:36:10.626][\examples\react][npm run preview][stderr] ERR!
|
|
241
|
+
// [15:36:10.626][\examples\react][npm run preview][stderr]
|
|
242
|
+
// [15:36:10.626][\examples\react][npm run preview][stderr] code
|
|
243
|
+
// [15:36:10.626][\examples\react][npm run preview][stderr] ELIFECYCLE
|
|
244
|
+
// ```
|
|
245
|
+
// Because stderr isn't empty, runTests() believes that the termination failed.
|
|
246
|
+
// - taskkill somtimes throws:
|
|
247
|
+
// ```
|
|
248
|
+
// ERROR: The process with PID 6052 (child process of PID 3184) could not be terminated.
|
|
249
|
+
// Reason: There is no running instance of the task.
|
|
250
|
+
// ```
|
|
251
|
+
// ```
|
|
252
|
+
// ERROR: The process "6564" not found.
|
|
253
|
+
// ```
|
|
254
|
+
// There doesn't seem to be an option to suppress these errors: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill#parameters
|
|
234
255
|
(0, child_process_1.spawn)('taskkill', ['/pid', String(proc.pid), '/f', '/t'], {
|
|
235
256
|
stdio: [
|
|
236
|
-
'
|
|
237
|
-
'
|
|
238
|
-
//
|
|
239
|
-
// ```
|
|
240
|
-
// ERROR: The process with PID 6052 (child process of PID 3184) could not be terminated.
|
|
241
|
-
// Reason: There is no running instance of the task.
|
|
242
|
-
// ```
|
|
243
|
-
// There doesn't seem to be an option to suppress that error: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill#parameters
|
|
257
|
+
'inherit',
|
|
258
|
+
'inherit',
|
|
259
|
+
// Ignoring stderr doesn't solve the problem that taskkill makes the process exit with code 1
|
|
244
260
|
'inherit', // stderr
|
|
245
261
|
],
|
|
246
262
|
});
|
|
@@ -248,6 +264,7 @@ function stopProcess({ proc, cwd, cmd, signal, }) {
|
|
|
248
264
|
else {
|
|
249
265
|
(0, utils_2.assert)(proc.pid);
|
|
250
266
|
const processGroup = -1 * proc.pid;
|
|
267
|
+
const signal = force ? 'SIGKILL' : 'SIGTERM';
|
|
251
268
|
process.kill(processGroup, signal);
|
|
252
269
|
/*
|
|
253
270
|
try {
|
|
@@ -288,7 +305,7 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
|
|
|
288
305
|
logText: err.message,
|
|
289
306
|
logSource: 'run() failure',
|
|
290
307
|
});
|
|
291
|
-
await terminate();
|
|
308
|
+
await terminate(true);
|
|
292
309
|
onFailure(err);
|
|
293
310
|
};
|
|
294
311
|
proc.stdin.on('data', async (data) => {
|
|
@@ -344,7 +361,7 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
|
|
|
344
361
|
function processHasExited() {
|
|
345
362
|
return procExited;
|
|
346
363
|
}
|
|
347
|
-
async function terminate(
|
|
364
|
+
async function terminate(force) {
|
|
348
365
|
let resolve;
|
|
349
366
|
let reject;
|
|
350
367
|
const promise = new Promise((_resolve, _reject) => {
|
|
@@ -368,7 +385,7 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
|
|
|
368
385
|
proc,
|
|
369
386
|
cwd,
|
|
370
387
|
cmd,
|
|
371
|
-
|
|
388
|
+
force,
|
|
372
389
|
});
|
|
373
390
|
}
|
|
374
391
|
catch (err) {
|