@brillout/test-e2e 0.3.8 → 0.3.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/Logs.d.ts CHANGED
@@ -14,9 +14,9 @@ declare type LogEntry = {
14
14
  logTimestamp: string;
15
15
  isNotFailure: boolean;
16
16
  };
17
- declare function hasErrorLogs(treatWarningAsError: boolean): boolean;
17
+ declare function hasErrorLogs(failOnWarning: boolean): boolean;
18
18
  declare function clearLogs(): void;
19
- declare function logErrors(treatWarningAsError: boolean): void;
19
+ declare function logErrors(failOnWarning: boolean): void;
20
20
  declare function flushLogs(): void;
21
21
  declare function add({ logSource, logText }: {
22
22
  logSource: LogSource;
package/dist/Logs.js CHANGED
@@ -17,11 +17,11 @@ const picocolors_1 = __importDefault(require("picocolors"));
17
17
  const getCurrentTest_1 = require("./getCurrentTest");
18
18
  const getConfig_1 = require("./getConfig");
19
19
  let logEntries = [];
20
- function hasErrorLogs(treatWarningAsError) {
21
- const errorLogs = getErrorLogs(treatWarningAsError);
20
+ function hasErrorLogs(failOnWarning) {
21
+ const errorLogs = getErrorLogs(failOnWarning);
22
22
  return errorLogs.length > 0;
23
23
  }
24
- function getErrorLogs(treatWarningAsError) {
24
+ function getErrorLogs(failOnWarning) {
25
25
  const errorLogs = logEntries.filter(({ logSource, isNotFailure }) => {
26
26
  if (isNotFailure) {
27
27
  return;
@@ -29,7 +29,7 @@ function getErrorLogs(treatWarningAsError) {
29
29
  if (logSource === 'run() failure') {
30
30
  return true;
31
31
  }
32
- if (treatWarningAsError && (logSource === 'Browser Warning' || logSource === 'stderr')) {
32
+ if (failOnWarning && (logSource === 'Browser Warning' || logSource === 'stderr')) {
33
33
  return true;
34
34
  }
35
35
  if (logSource === 'Browser Error') {
@@ -42,11 +42,12 @@ function getErrorLogs(treatWarningAsError) {
42
42
  function clearLogs() {
43
43
  logEntries = [];
44
44
  }
45
- function logErrors(treatWarningAsError) {
46
- const errorLogs = getErrorLogs(treatWarningAsError);
45
+ function logErrors(failOnWarning) {
46
+ const errorLogs = getErrorLogs(failOnWarning);
47
47
  errorLogs.forEach((logEntry) => printLog(logEntry));
48
48
  }
49
49
  function flushLogs() {
50
+ console.log(picocolors_1.default.bold('vvvv ALL LOGS vvvv'));
50
51
  logEntries.forEach((logEntry) => printLog(logEntry));
51
52
  logEntries = [];
52
53
  }
@@ -98,7 +99,7 @@ function printLog(logEntry) {
98
99
  const testInfo = (0, getCurrentTest_1.getCurrentTestOptional)();
99
100
  // See https://github.com/nodejs/node/issues/8033#issuecomment-388323687
100
101
  if (!(0, utils_1.ensureNewTerminalLine)()) {
101
- process.stderr.write(`\n`);
102
+ console.log('');
102
103
  }
103
104
  let msg = logText;
104
105
  // I don't know why but sometimes `logText` is `undefined`
@@ -111,7 +112,7 @@ function printLog(logEntry) {
111
112
  (0, utils_1.assert)(testInfo.runInfo);
112
113
  testInfoLabels = `[${testInfo.testName}][${testInfo.runInfo.cmd}]`;
113
114
  }
114
- process.stderr.write(`[${logTimestamp}]${testInfoLabels}[${logSourceLabel}] ${msg}`);
115
+ console.log(`[${logTimestamp}]${testInfoLabels}[${logSourceLabel}] ${msg}`);
115
116
  }
116
117
  function colorize(logSource) {
117
118
  const { bold } = picocolors_1.default;
package/dist/runTests.js CHANGED
@@ -61,13 +61,10 @@ async function runTests(browser) {
61
61
  if (isFailure) {
62
62
  logTestsResult(false);
63
63
  if (err) {
64
- console.error(err);
64
+ console.log(err);
65
65
  }
66
- if (hasErrorLog) {
66
+ else 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'));
71
68
  }
72
69
  Logs_1.Logs.flushLogs();
73
70
  process.exit(1);
@@ -135,11 +132,13 @@ function logTestsResult(success) {
135
132
  console.log(`${failStyle(' FAIL ')} ${testInfo.testFile}`);
136
133
  }
137
134
  }
138
- function logIsFailure(isTermination, canBeAWarning) {
135
+ function logIsFailure(isTermination, failOnWarning) {
139
136
  console.log(picocolors_1.default.red(picocolors_1.default.bold([
140
137
  'Test FAIL because encountered an error',
141
- !canBeAWarning ? '' : ' or warning',
138
+ !failOnWarning ? '' : ' or warning',
142
139
  !isTermination ? '' : ' during termination',
143
140
  ', see logs below.',
144
141
  ].join(''))));
142
+ console.log(picocolors_1.default.bold('vvvv FAIL LOG vvvv'));
143
+ Logs_1.Logs.logErrors(failOnWarning);
145
144
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {