@brillout/test-e2e 0.4.9 → 0.4.10

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/runTests.js CHANGED
@@ -16,10 +16,12 @@ const buildTs_1 = require("./buildTs");
16
16
  const findTestFiles_1 = require("./findTestFiles");
17
17
  const getConfig_1 = require("./getConfig");
18
18
  const logError_1 = require("./logError");
19
+ let hasFailure = false;
19
20
  async function runTests(filter) {
20
21
  await (0, getConfig_1.loadConfig)();
21
22
  const testFiles = await (0, findTestFiles_1.findTestFiles)(filter);
22
23
  const browser = await (0, getBrowser_1.getBrowser)();
24
+ let hasFailedTest = false;
23
25
  for (const testFile of testFiles) {
24
26
  (0, utils_1.assert)(testFile.endsWith('.ts'));
25
27
  const testFileJs = testFile.replace('.ts', '.mjs');
@@ -31,11 +33,20 @@ async function runTests(filter) {
31
33
  finally {
32
34
  clean();
33
35
  }
34
- await runTestFile(browser);
36
+ const success = await runTestFile(browser);
37
+ if (!success) {
38
+ hasFailedTest = true;
39
+ }
35
40
  (0, getCurrentTest_2.setCurrentTest)(null);
36
41
  (0, utils_1.assert)(testFileJs.endsWith('.mjs'));
37
42
  }
38
43
  await browser.close();
44
+ if (hasFailedTest || hasFailure) {
45
+ // hasFailedTest and hasFailure are redundant
46
+ // - When assert.ts calls logFailure() this code block isn't run
47
+ (0, utils_1.assert)(hasFailedTest && hasFailure);
48
+ throw new Error('A test failed. See messages above.');
49
+ }
39
50
  }
40
51
  exports.runTests = runTests;
41
52
  async function runTestFile(browser) {
@@ -51,7 +62,7 @@ async function runTestFile(browser) {
51
62
  logTestStatus(false);
52
63
  (0, utils_1.assertUsage)(!testInfo.runInfo, 'You cannot call `run()` after calling `skip()`');
53
64
  (0, utils_1.assertUsage)(testInfo.tests === undefined, 'You cannot call `test()` after calling `skip()`');
54
- return;
65
+ return true;
55
66
  }
56
67
  // Set when user calls `run()`
57
68
  (0, utils_1.assert)(testInfo.runInfo);
@@ -77,7 +88,7 @@ async function runTestFile(browser) {
77
88
  (0, logError_1.logError)(err);
78
89
  Logs_1.Logs.flushLogs();
79
90
  await abort();
80
- return;
91
+ return false;
81
92
  }
82
93
  for (const { testDesc, testFn } of testInfo.tests) {
83
94
  Logs_1.Logs.add({
@@ -112,7 +123,7 @@ async function runTestFile(browser) {
112
123
  Logs_1.Logs.logErrors(failOnWarning);
113
124
  Logs_1.Logs.flushLogs();
114
125
  await abort();
115
- return;
126
+ return false;
116
127
  }
117
128
  }
118
129
  Logs_1.Logs.clearLogs();
@@ -128,11 +139,12 @@ async function runTestFile(browser) {
128
139
  Logs_1.Logs.logErrors(failOnWarning);
129
140
  Logs_1.Logs.flushLogs();
130
141
  await abort();
131
- return;
142
+ return false;
132
143
  }
133
144
  }
134
145
  Logs_1.Logs.clearLogs();
135
146
  logTestStatus(true);
147
+ return true;
136
148
  }
137
149
  function getErrorType(failOnWarning) {
138
150
  return !failOnWarning ? 'error(s)' : 'error(s)/warning(s)';
@@ -178,6 +190,7 @@ function logTestStatus(success) {
178
190
  }
179
191
  }
180
192
  function logFailure(reason) {
193
+ hasFailure = true;
181
194
  logTestStatus(false);
182
195
  const { FAIL } = getStatusTags();
183
196
  const color = (s) => picocolors_1.default.red(picocolors_1.default.bold(s));
package/dist/setup.js CHANGED
@@ -243,7 +243,7 @@ function stopProcess({ proc, cwd, cmd, force, }) {
243
243
  // [15:36:10.626][\examples\react][npm run preview][stderr] ELIFECYCLE
244
244
  // ```
245
245
  // Because stderr isn't empty, runTests() believes that the termination failed.
246
- // - taskkill somtimes throws:
246
+ // - taskkill sometimes throws:
247
247
  // ```
248
248
  // ERROR: The process with PID 6052 (child process of PID 3184) could not be terminated.
249
249
  // Reason: There is no running instance of the task.
@@ -318,7 +318,7 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
318
318
  logSource: 'stdout',
319
319
  logText: data,
320
320
  });
321
- /* These assertions sometimes fails, see comments in assertNotExited()
321
+ /* These assertions sometimes fail, see comments in assertNotExited()
322
322
  assertNotExited(data)
323
323
  assert(getRunInfo().cmd === cmd)
324
324
  /*/
@@ -333,7 +333,7 @@ function execRunScript({ onStdout, onFailure, onExit, }) {
333
333
  logSource: 'stderr',
334
334
  logText: data,
335
335
  });
336
- /* These assertions sometimes fails, see comments in assertNotExited()
336
+ /* These assertions sometimes fail, see comments in assertNotExited()
337
337
  assertNotExited(data)
338
338
  assert(getRunInfo().cmd === cmd)
339
339
  /*/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {