@brillout/test-e2e 0.3.7 → 0.3.8

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.d.ts CHANGED
@@ -2,6 +2,7 @@ export { expectError };
2
2
  export declare const Logs: {
3
3
  add: typeof add;
4
4
  flushLogs: typeof flushLogs;
5
+ logErrors: typeof logErrors;
5
6
  clearLogs: typeof clearLogs;
6
7
  hasErrorLogs: typeof hasErrorLogs;
7
8
  flushEagerly: boolean;
@@ -13,8 +14,9 @@ declare type LogEntry = {
13
14
  logTimestamp: string;
14
15
  isNotFailure: boolean;
15
16
  };
16
- declare function hasErrorLogs(doNotFailOnWarning?: boolean): boolean;
17
+ declare function hasErrorLogs(treatWarningAsError: boolean): boolean;
17
18
  declare function clearLogs(): void;
19
+ declare function logErrors(treatWarningAsError: boolean): void;
18
20
  declare function flushLogs(): void;
19
21
  declare function add({ logSource, logText }: {
20
22
  logSource: LogSource;
package/dist/Logs.js CHANGED
@@ -7,6 +7,7 @@ exports.Logs = exports.expectError = void 0;
7
7
  exports.Logs = {
8
8
  add,
9
9
  flushLogs,
10
+ logErrors,
10
11
  clearLogs,
11
12
  hasErrorLogs,
12
13
  flushEagerly: false,
@@ -16,15 +17,19 @@ const picocolors_1 = __importDefault(require("picocolors"));
16
17
  const getCurrentTest_1 = require("./getCurrentTest");
17
18
  const getConfig_1 = require("./getConfig");
18
19
  let logEntries = [];
19
- function hasErrorLogs(doNotFailOnWarning = false) {
20
- const logErrors = logEntries.filter(({ logSource, isNotFailure }) => {
20
+ function hasErrorLogs(treatWarningAsError) {
21
+ const errorLogs = getErrorLogs(treatWarningAsError);
22
+ return errorLogs.length > 0;
23
+ }
24
+ function getErrorLogs(treatWarningAsError) {
25
+ const errorLogs = logEntries.filter(({ logSource, isNotFailure }) => {
21
26
  if (isNotFailure) {
22
27
  return;
23
28
  }
24
29
  if (logSource === 'run() failure') {
25
30
  return true;
26
31
  }
27
- if (!doNotFailOnWarning && (logSource === 'Browser Warning' || logSource === 'stderr')) {
32
+ if (treatWarningAsError && (logSource === 'Browser Warning' || logSource === 'stderr')) {
28
33
  return true;
29
34
  }
30
35
  if (logSource === 'Browser Error') {
@@ -32,11 +37,15 @@ function hasErrorLogs(doNotFailOnWarning = false) {
32
37
  }
33
38
  return false;
34
39
  });
35
- return logErrors.length > 0;
40
+ return errorLogs;
36
41
  }
37
42
  function clearLogs() {
38
43
  logEntries = [];
39
44
  }
45
+ function logErrors(treatWarningAsError) {
46
+ const errorLogs = getErrorLogs(treatWarningAsError);
47
+ errorLogs.forEach((logEntry) => printLog(logEntry));
48
+ }
40
49
  function flushLogs() {
41
50
  logEntries.forEach((logEntry) => printLog(logEntry));
42
51
  logEntries = [];
package/dist/runTests.js CHANGED
@@ -56,7 +56,7 @@ async function runTests(browser) {
56
56
  done(!!err);
57
57
  testInfo.afterEach(!!err);
58
58
  const { doNotFailOnWarning } = testInfo.runInfo;
59
- const hasErrorLog = Logs_1.Logs.hasErrorLogs(doNotFailOnWarning);
59
+ const hasErrorLog = Logs_1.Logs.hasErrorLogs(!doNotFailOnWarning);
60
60
  const isFailure = err || hasErrorLog;
61
61
  if (isFailure) {
62
62
  logTestsResult(false);
@@ -65,6 +65,9 @@ async function runTests(browser) {
65
65
  }
66
66
  if (hasErrorLog) {
67
67
  logIsFailure(false, !doNotFailOnWarning);
68
+ console.log(picocolors_1.default.bold('vvvv FAIL LOGS vvvv'));
69
+ Logs_1.Logs.logErrors(!doNotFailOnWarning);
70
+ console.log(picocolors_1.default.bold('vvvv ALL LOGS vvvv'));
68
71
  }
69
72
  Logs_1.Logs.flushLogs();
70
73
  process.exit(1);
@@ -76,7 +79,7 @@ async function runTests(browser) {
76
79
  await testInfo.terminateServer();
77
80
  await page.close();
78
81
  // Handle case that an error occured during `terminateServer()`
79
- if (Logs_1.Logs.hasErrorLogs()) {
82
+ if (Logs_1.Logs.hasErrorLogs(true)) {
80
83
  if ((0, utils_1.isWindows)()) {
81
84
  // On Windows, the sever sometimes terminates with an exit code of `1`. I don't know why.
82
85
  Logs_1.Logs.clearLogs();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {