@brillout/test-e2e 0.4.0 → 0.4.1

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.js CHANGED
@@ -46,7 +46,7 @@ function clearLogs() {
46
46
  function logErrors(failOnWarning) {
47
47
  if (!exports.Logs.hasErrorLogs(failOnWarning))
48
48
  return;
49
- (0, logSection_1.logSection)(`ERROR${!failOnWarning ? '' : '/WARNING'} LOG(S)`);
49
+ (0, logSection_1.logSection)(`ERROR${!failOnWarning ? '' : '/WARNING'} LOGS`);
50
50
  const errorLogs = getErrorLogs(failOnWarning);
51
51
  errorLogs.forEach((logEntry) => printLog(logEntry));
52
52
  }
@@ -6,6 +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
+ console.log();
10
+ console.log();
11
+ console.log();
9
12
  console.log(picocolors_1.default.bold(`vvvvvv ${sectionTitle} vvvvvv`));
10
13
  }
11
14
  exports.logSection = logSection;
package/dist/runTests.js CHANGED
@@ -74,7 +74,7 @@ async function runTestFile(browser) {
74
74
  }
75
75
  catch (err) {
76
76
  logResult(false);
77
- logFailureReason('during server start', false);
77
+ logFailureReason('an error occurred while starting the server');
78
78
  logError(err);
79
79
  Logs_1.Logs.flushLogs();
80
80
  await abort();
@@ -101,13 +101,12 @@ async function runTestFile(browser) {
101
101
  const isFailure = err || hasErrorLog;
102
102
  if (isFailure) {
103
103
  logResult(false);
104
- const failureContext = 'while running the tests';
105
104
  if (err) {
106
- logFailureReason(failureContext, false);
105
+ logFailureReason(`the test "${testDesc}" threw an error`);
107
106
  logError(err);
108
107
  }
109
108
  else if (hasErrorLog) {
110
- logFailureReason(failureContext, true, failOnWarning);
109
+ logFailureReason(`${getErrorType(failOnWarning)} occurred while running the test "${testDesc}"`);
111
110
  }
112
111
  else {
113
112
  (0, utils_1.assert)(false);
@@ -121,23 +120,23 @@ async function runTestFile(browser) {
121
120
  Logs_1.Logs.clearLogs();
122
121
  }
123
122
  await clean();
124
- // Handle case that an error occured during `testInfo.terminateServer()`
125
- if (Logs_1.Logs.hasErrorLogs(true)) {
126
- /* TODO: implement more precise workaround
127
- if (isWindows()) {
128
- // On Windows, the sever sometimes terminates with an exit code of `1`. I don't know why.
129
- Logs.clearLogs()
130
- } else {
131
- */
132
- const failOnWarning = false;
133
- logFailureReason('during server termination', true, failOnWarning);
134
- Logs_1.Logs.logErrors(failOnWarning);
135
- Logs_1.Logs.flushLogs();
136
- await abort();
137
- return;
123
+ // Check whether stderr emitted during testInfo.terminateServer()
124
+ {
125
+ const failOnWarning = true;
126
+ if (Logs_1.Logs.hasErrorLogs(failOnWarning)) {
127
+ logFailureReason(`${getErrorType(failOnWarning)} occurred during server termination`);
128
+ Logs_1.Logs.logErrors(failOnWarning);
129
+ Logs_1.Logs.flushLogs();
130
+ await abort();
131
+ return;
132
+ }
138
133
  }
134
+ Logs_1.Logs.clearLogs();
139
135
  logResult(true);
140
136
  }
137
+ function getErrorType(failOnWarning) {
138
+ return !failOnWarning ? 'error(s)' : 'error(s)/warning(s)';
139
+ }
141
140
  function runTest(testFn, testFunctionTimeout) {
142
141
  let resolve;
143
142
  let reject;
@@ -178,13 +177,11 @@ function logResult(success) {
178
177
  console.log(`${FAIL} ${testInfo.testFile}`);
179
178
  }
180
179
  }
181
- function logFailureReason(context, isErrorLog, failOnWarning) {
180
+ function logFailureReason(reason) {
181
+ const testInfo = (0, getCurrentTest_1.getCurrentTest)();
182
182
  const { FAIL } = getStatusTags();
183
183
  const color = (s) => picocolors_1.default.red(picocolors_1.default.bold(s));
184
- (0, utils_1.assert)((isErrorLog === false && failOnWarning === undefined) ||
185
- (isErrorLog === true && (failOnWarning === true || failOnWarning === false)));
186
- const errType = isErrorLog ? 'error' : !failOnWarning ? 'error(s)' : 'error(s)/warning(s)';
187
- const msg = `Test ${FAIL} because encountered ${errType} ${context}, see below.`;
184
+ const msg = `Test ${testInfo.testFile} ${FAIL} because ${reason}, see below.`;
188
185
  console.log(color(msg));
189
186
  }
190
187
  function logError(err) {
@@ -192,8 +189,8 @@ function logError(err) {
192
189
  console.log(err);
193
190
  }
194
191
  function getStatusTags() {
195
- const PASS = picocolors_1.default.bold(picocolors_1.default.bgGreen('PASS'));
196
- const FAIL = picocolors_1.default.bold(picocolors_1.default.bgRed('FAIL'));
197
- const WARN = picocolors_1.default.bold(picocolors_1.default.bgYellow('WARN'));
192
+ const PASS = picocolors_1.default.bold(picocolors_1.default.bgGreen(picocolors_1.default.white(' PASS ')));
193
+ const FAIL = picocolors_1.default.bold(picocolors_1.default.bgRed(picocolors_1.default.white(' FAIL ')));
194
+ const WARN = picocolors_1.default.bold(picocolors_1.default.bgYellow(picocolors_1.default.white(' WARN ')));
198
195
  return { PASS, FAIL, WARN };
199
196
  }
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.isLinux)() ? 1 : 4);
29
+ const TIMEOUT_PROCESS_TERMINATION = 10 * 1000 * (!(0, utils_1.isCI)() ? 1 : (0, utils_1.isWindows)() ? 10 : !(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) {
@@ -357,7 +357,10 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
357
357
  logSource: 'run() failure',
358
358
  logText: errMsg,
359
359
  });
360
- reject(new Error(errMsg));
360
+ /* Don't interrupt the test runner, as the test runner may recover thanks to the process-killing-by-port
361
+ reject(new Error(errMsg))
362
+ */
363
+ resolve();
361
364
  }, TIMEOUT_PROCESS_TERMINATION);
362
365
  (0, utils_2.assert)(proc);
363
366
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {