@brillout/test-e2e 0.6.9 → 0.6.11

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
@@ -12,6 +12,7 @@ type LogSource = 'stdout' | 'stderr' | 'Browser Error' | 'Browser Warning' | 'Br
12
12
  type LogEntry = {
13
13
  logSource: LogSource;
14
14
  logText: string;
15
+ logInfo: string;
15
16
  logTimestamp: string;
16
17
  isNotFailure: boolean;
17
18
  loggedAfterExit: boolean;
@@ -20,9 +21,10 @@ declare function hasFailLogs(failOnWarning: boolean): boolean;
20
21
  declare function clearLogs(): void;
21
22
  declare function logErrorsAndWarnings(): void;
22
23
  declare function flushLogs(): void;
23
- declare function add({ logSource, logText, loggedAfterExit, }: {
24
+ declare function add({ logSource, logText, logInfo, loggedAfterExit, }: {
24
25
  logSource: LogSource;
25
26
  logText: string;
27
+ logInfo?: string;
26
28
  loggedAfterExit?: boolean;
27
29
  }): void;
28
30
  /**
package/dist/Logs.js CHANGED
@@ -7,9 +7,9 @@ export const Logs = {
7
7
  hasFailLogs,
8
8
  logEagerly: false,
9
9
  };
10
- import { assert, ensureNewTerminalLine, isWindows } from './utils.js';
10
+ import { assert, cliOptions, ensureNewTerminalLine, isWindows } from './utils.js';
11
11
  import pc from '@brillout/picocolors';
12
- import { getCurrentTestOptional } from './getCurrentTest.js';
12
+ import { getCurrentTest, getCurrentTestOptional } from './getCurrentTest.js';
13
13
  import { logSection } from './logSection.js';
14
14
  import { isTolerateError } from './Logs/isTolerateError.js';
15
15
  import stripAnsi from 'strip-ansi';
@@ -57,11 +57,12 @@ function flushLogs() {
57
57
  logEntries.filter((logEntry) => !logEntry.loggedAfterExit).forEach((logEntry) => printLog(logEntry));
58
58
  logEntries = [];
59
59
  }
60
- function add({ logSource, logText, loggedAfterExit = false, }) {
60
+ function add({ logSource, logText, logInfo = '', loggedAfterExit = false, }) {
61
61
  const logTimestamp = getTimestamp();
62
62
  const logEntry = {
63
63
  logSource,
64
64
  logText,
65
+ logInfo,
65
66
  logTimestamp,
66
67
  isNotFailure: isTolerateError({ logSource, logText }),
67
68
  loggedAfterExit,
@@ -77,6 +78,25 @@ function add({ logSource, logText, loggedAfterExit = false, }) {
77
78
  if (shouldLog)
78
79
  printLog(logEntry);
79
80
  }
81
+ if (logSource === 'Browser Error' || logSource === 'stderr') {
82
+ terminateUponErrorLog();
83
+ }
84
+ }
85
+ async function terminateUponErrorLog() {
86
+ if (!cliOptions.bail)
87
+ return;
88
+ const testInfo = getCurrentTest();
89
+ testInfo.aborted = true;
90
+ // Trick to abort the test: page.close() triggers the following error.
91
+ // ```console
92
+ // proxy.waitForFunction: Target closed
93
+ // at clientSideNavigation (.testRun.ts:16:16)
94
+ // at .testRun.ts:11:5
95
+ // at file:///home/rom/code/test-e2e/src/runAll.ts:278:7 {
96
+ // name: 'Error'
97
+ // }
98
+ // ```
99
+ await testInfo.page.close();
80
100
  }
81
101
  /**
82
102
  * Expect a log to be printed.
package/dist/run.js CHANGED
@@ -69,12 +69,11 @@ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect
69
69
  };
70
70
  return;
71
71
  // Also called when the page throws an error or a warning
72
- async function onConsole(msg) {
72
+ function onConsole(msg) {
73
73
  const type = msg.type();
74
- const isError = type === 'error';
75
74
  Logs.add({
76
75
  logSource: (() => {
77
- if (isError) {
76
+ if (type === 'error') {
78
77
  return 'Browser Error';
79
78
  }
80
79
  if (type === 'warning') {
@@ -83,24 +82,15 @@ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect
83
82
  return 'Browser Log';
84
83
  })(),
85
84
  logText: msg.text(),
86
- /* Seems like the information below isn't that useful.
87
- JSON.stringify(
88
- {
85
+ logInfo: JSON.stringify({
89
86
  type,
90
- text: msg.text(),
91
87
  location: msg.location(),
92
88
  args: msg.args(),
93
- },
94
- null,
95
- 2,
96
- ),
97
- */
89
+ }, null, 2),
98
90
  });
99
- if (isError)
100
- await terminateUponBrowserError();
101
91
  }
102
92
  // For uncaught exceptions
103
- async function onPageError(err) {
93
+ function onPageError(err) {
104
94
  Logs.add({
105
95
  logSource: 'Browser Error',
106
96
  logText: JSON.stringify({
@@ -108,22 +98,6 @@ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect
108
98
  location: err.stack,
109
99
  }, null, 2),
110
100
  });
111
- await terminateUponBrowserError();
112
- }
113
- async function terminateUponBrowserError() {
114
- if (!cliOptions.bail)
115
- return;
116
- testInfo.aborted = true;
117
- // Trick to abort the test: page.close() triggers the following error.
118
- // ```console
119
- // proxy.waitForFunction: Target closed
120
- // at clientSideNavigation (.testRun.ts:16:16)
121
- // at .testRun.ts:11:5
122
- // at file:///home/rom/code/test-e2e/src/runAll.ts:278:7 {
123
- // name: 'Error'
124
- // }
125
- // ```
126
- await testInfo.page.close();
127
101
  }
128
102
  }
129
103
  async function startProcess({ serverIsReadyMessage, serverIsReadyDelay, additionalTimeout, cmd, }) {
@@ -1,10 +1,11 @@
1
1
  export { cliOptions };
2
2
  import { check, prepare, validate } from './parseCli.js';
3
+ import { isCI } from './platform.js';
3
4
  prepare();
4
5
  const verbose = check('--verbose');
5
6
  const inspect = check('--inspect');
6
7
  const debugEsbuild = check('--debug-esbuild');
7
- const bail = check('--bail');
8
+ const bail = check('--bail') || !isCI();
8
9
  // Defined & used in ./findFiles.ts
9
10
  const exclude = check('--exclude');
10
11
  validate();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.6.9",
3
+ "version": "0.6.11",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",