@brillout/test-e2e 0.6.10 → 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.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';
@@ -78,6 +78,25 @@ function add({ logSource, logText, logInfo = '', loggedAfterExit = false, }) {
78
78
  if (shouldLog)
79
79
  printLog(logEntry);
80
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();
81
100
  }
82
101
  /**
83
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') {
@@ -89,11 +88,9 @@ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect
89
88
  args: msg.args(),
90
89
  }, null, 2),
91
90
  });
92
- if (isError)
93
- await terminateUponBrowserError();
94
91
  }
95
92
  // For uncaught exceptions
96
- async function onPageError(err) {
93
+ function onPageError(err) {
97
94
  Logs.add({
98
95
  logSource: 'Browser Error',
99
96
  logText: JSON.stringify({
@@ -101,22 +98,6 @@ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect
101
98
  location: err.stack,
102
99
  }, null, 2),
103
100
  });
104
- await terminateUponBrowserError();
105
- }
106
- async function terminateUponBrowserError() {
107
- if (!cliOptions.bail)
108
- return;
109
- testInfo.aborted = true;
110
- // Trick to abort the test: page.close() triggers the following error.
111
- // ```console
112
- // proxy.waitForFunction: Target closed
113
- // at clientSideNavigation (.testRun.ts:16:16)
114
- // at .testRun.ts:11:5
115
- // at file:///home/rom/code/test-e2e/src/runAll.ts:278:7 {
116
- // name: 'Error'
117
- // }
118
- // ```
119
- await testInfo.page.close();
120
101
  }
121
102
  }
122
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.10",
3
+ "version": "0.6.11",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",