@brillout/test-e2e 0.4.2 → 0.4.4

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,9 @@ 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
- const title = `------ ${sectionTitle} ------`;
9
+ const title = `vvvvvv ${sectionTitle} vvvvvv`;
10
10
  const width = title.length;
11
- console.log(picocolors_1.default.bold('='.repeat(width)));
11
+ console.log(picocolors_1.default.bold('v'.repeat(width)));
12
12
  console.log(picocolors_1.default.bold(title));
13
13
  console.log(picocolors_1.default.bold('v'.repeat(width)));
14
14
  }
package/dist/runTests.js CHANGED
@@ -121,7 +121,9 @@ async function runTestFile(browser) {
121
121
  // Check whether stderr emitted during testInfo.terminateServer()
122
122
  {
123
123
  const failOnWarning = true;
124
- 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)()) {
125
127
  logFailureReason(`${getErrorType(failOnWarning)} occurred during server termination`);
126
128
  Logs_1.Logs.logErrors(failOnWarning);
127
129
  Logs_1.Logs.flushLogs();
package/dist/setup.js CHANGED
@@ -231,30 +231,33 @@ function stopProcess({ proc, cwd, cmd, force, }) {
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
- 'ignore',
237
- 'ignore',
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
- // ```
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
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
257
+ 'inherit',
258
+ 'inherit',
259
+ // Ignoring stderr doesn't solve the problem that taskkill makes the process exit with code 1
260
+ 'inherit', // stderr
258
261
  ],
259
262
  });
260
263
  }
@@ -309,7 +312,7 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
309
312
  await exitAndFail(new Error(`Command is \`${cmd}\` (${cwd}) is invoking \`stdin\`: ${data}.`));
310
313
  });
311
314
  proc.stdout.on('data', (data) => {
312
- (0, utils_2.assert)(!procExited);
315
+ assertNotExited(data);
313
316
  (0, utils_2.assert)(getRunInfo().cmd === cmd);
314
317
  data = data.toString();
315
318
  Logs_1.Logs.add({
@@ -319,7 +322,7 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
319
322
  onStdout?.(data);
320
323
  });
321
324
  proc.stderr.on('data', async (data) => {
322
- (0, utils_2.assert)(!procExited);
325
+ assertNotExited(data);
323
326
  (0, utils_2.assert)(getRunInfo().cmd === cmd);
324
327
  data = data.toString();
325
328
  Logs_1.Logs.add({
@@ -355,6 +358,17 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
355
358
  exitPromiseResolve();
356
359
  });
357
360
  return { terminate, processHasExited };
361
+ function assertNotExited(data) {
362
+ if (!procExited)
363
+ return;
364
+ Logs_1.Logs.logErrors(true);
365
+ Logs_1.Logs.flushLogs();
366
+ console.log('getCurrentTest()', (0, getCurrentTest_1.getCurrentTest)());
367
+ console.log('data', data);
368
+ console.log('cmd', cmd);
369
+ console.log('process.platform', process.platform);
370
+ (0, utils_2.assert)(false);
371
+ }
358
372
  function processHasExited() {
359
373
  return procExited;
360
374
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {