@brillout/test-e2e 0.4.1 → 0.4.2

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.
@@ -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
- console.log();
10
- console.log();
11
- console.log();
12
- console.log(picocolors_1.default.bold(`vvvvvv ${sectionTitle} vvvvvv`));
9
+ const title = `------ ${sectionTitle} ------`;
10
+ const width = title.length;
11
+ console.log(picocolors_1.default.bold('='.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);
@@ -178,10 +176,10 @@ function logResult(success) {
178
176
  }
179
177
  }
180
178
  function logFailureReason(reason) {
181
- const testInfo = (0, getCurrentTest_1.getCurrentTest)();
179
+ logResult(false);
182
180
  const { FAIL } = getStatusTags();
183
181
  const color = (s) => picocolors_1.default.red(picocolors_1.default.bold(s));
184
- const msg = `Test ${testInfo.testFile} ${FAIL} because ${reason}, see below.`;
182
+ const msg = `Test ${FAIL} because ${reason}, see below.`;
185
183
  console.log(color(msg));
186
184
  }
187
185
  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)() ? 10 : !(0, utils_1.isLinux)() ? 3 : 1);
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('SIGINT');
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, signal, }) {
213
+ function stopProcess({ proc, cwd, cmd, force, }) {
214
214
  const prefix = `[Run Stop][${cwd}][${cmd}]`;
215
215
  let resolve;
216
216
  let reject;
@@ -235,19 +235,33 @@ function stopProcess({ proc, cwd, cmd, signal, }) {
235
235
  stdio: [
236
236
  'ignore',
237
237
  'ignore',
238
- // Should we ignore `stderr`? Because `taskkill` somtimes throws:
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
- // ```
238
+ // We ignore stderr because taskkill somtimes throws:
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
+ // ```
244
+ // ERROR: The process "6564" not found.
245
+ // ```
243
246
  // 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
244
- 'inherit', // stderr
247
+ // The error propagates to Node.js's stderr.
248
+ // ```
249
+ // [15:36:10.626][\examples\react][npm run preview][stderr] npm
250
+ // [15:36:10.626][\examples\react][npm run preview][stderr]
251
+ // [15:36:10.626][\examples\react][npm run preview][stderr] ERR!
252
+ // [15:36:10.626][\examples\react][npm run preview][stderr]
253
+ // [15:36:10.626][\examples\react][npm run preview][stderr] code
254
+ // [15:36:10.626][\examples\react][npm run preview][stderr] ELIFECYCLE
255
+ // ```
256
+ // Because stderr isn't empty, runTests() believes that the termination failed.
257
+ 'ignore', // stderr
245
258
  ],
246
259
  });
247
260
  }
248
261
  else {
249
262
  (0, utils_2.assert)(proc.pid);
250
263
  const processGroup = -1 * proc.pid;
264
+ const signal = force ? 'SIGKILL' : 'SIGTERM';
251
265
  process.kill(processGroup, signal);
252
266
  /*
253
267
  try {
@@ -288,7 +302,7 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
288
302
  logText: err.message,
289
303
  logSource: 'run() failure',
290
304
  });
291
- await terminate();
305
+ await terminate(true);
292
306
  onFailure(err);
293
307
  };
294
308
  proc.stdin.on('data', async (data) => {
@@ -344,7 +358,7 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
344
358
  function processHasExited() {
345
359
  return procExited;
346
360
  }
347
- async function terminate(signal = 'SIGKILL') {
361
+ async function terminate(force) {
348
362
  let resolve;
349
363
  let reject;
350
364
  const promise = new Promise((_resolve, _reject) => {
@@ -368,7 +382,7 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
368
382
  proc,
369
383
  cwd,
370
384
  cmd,
371
- signal,
385
+ force,
372
386
  });
373
387
  }
374
388
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {