@brillout/test-e2e 0.1.13 → 0.1.15

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
@@ -3,17 +3,17 @@ export declare const Logs: {
3
3
  add: typeof add;
4
4
  flush: typeof flush;
5
5
  clear: typeof clear;
6
- getBrowserErrors: typeof getBrowserErrors;
6
+ hasError: typeof hasError;
7
7
  flushEagerly: boolean;
8
8
  };
9
- declare type LogSource = 'stdout' | 'stderr' | 'Browser Error' | 'Browser Log' | 'Playwright' | 'run()' | 'test()' | 'Connection Error';
9
+ declare type LogSource = 'stdout' | 'stderr' | 'Browser Error' | 'Browser Warning' | 'Browser Log' | 'Playwright' | 'run()' | 'test()' | 'Connection Error';
10
10
  declare type LogEntry = {
11
11
  logSource: LogSource;
12
12
  logText: string;
13
13
  logTimestamp: string;
14
14
  isExpectedError: boolean;
15
15
  };
16
- declare function getBrowserErrors(): LogEntry[];
16
+ declare function hasError(onlyFailOnBrowserError: boolean): boolean;
17
17
  declare function clear(): void;
18
18
  declare function flush(): void;
19
19
  declare function add({ logSource, logText }: {
package/dist/Logs.js CHANGED
@@ -8,7 +8,7 @@ exports.Logs = {
8
8
  add,
9
9
  flush,
10
10
  clear,
11
- getBrowserErrors,
11
+ hasError,
12
12
  flushEagerly: false,
13
13
  };
14
14
  const utils_1 = require("./utils");
@@ -16,8 +16,20 @@ const picocolors_1 = __importDefault(require("picocolors"));
16
16
  const getCurrentTest_1 = require("./getCurrentTest");
17
17
  let logEntries = [];
18
18
  let logEntriesNotPrinted = [];
19
- function getBrowserErrors() {
20
- return logEntries.filter(({ logSource, isExpectedError }) => logSource === 'Browser Error' && !isExpectedError);
19
+ function hasError(onlyFailOnBrowserError) {
20
+ const logErrors = logEntries.filter(({ logSource, isExpectedError }) => {
21
+ if (isExpectedError) {
22
+ return;
23
+ }
24
+ if (!onlyFailOnBrowserError && (logSource === 'Browser Warning' || logSource === 'stderr')) {
25
+ return true;
26
+ }
27
+ if (logSource === 'Browser Error') {
28
+ return true;
29
+ }
30
+ return false;
31
+ });
32
+ return logErrors.length > 0;
21
33
  }
22
34
  function clear() {
23
35
  logEntries = [];
@@ -85,11 +97,13 @@ function colorize(logSource) {
85
97
  const { bold } = picocolors_1.default;
86
98
  if (logSource === 'stderr' || logSource === 'Browser Error' || logSource === 'Connection Error')
87
99
  return bold(picocolors_1.default.red(logSource));
100
+ if (logSource === 'Browser Warning')
101
+ return bold(picocolors_1.default.yellow(logSource));
88
102
  if (logSource === 'stdout' || logSource === 'Browser Log')
89
103
  return bold(picocolors_1.default.blue(logSource));
90
104
  if (logSource === 'Playwright')
91
105
  return bold(picocolors_1.default.magenta(logSource));
92
106
  if (logSource === 'run()' || logSource === 'test()')
93
- return bold(picocolors_1.default.yellow(logSource));
107
+ return bold(picocolors_1.default.cyan(logSource));
94
108
  (0, utils_1.assert)(false);
95
109
  }
@@ -17,6 +17,7 @@ declare type TestInfo = {
17
17
  serverIsReadyMessage?: string;
18
18
  serverIsReadyDelay: number;
19
19
  inspect: boolean;
20
+ onlyFailOnBrowserError: boolean;
20
21
  };
21
22
  hasStartedRunning?: boolean;
22
23
  skipped?: string;
package/dist/runTests.js CHANGED
@@ -52,16 +52,15 @@ async function runTests(browser) {
52
52
  }
53
53
  done(!!err);
54
54
  testInfo.afterEach(!!err);
55
- const browserErrors = Logs_1.Logs.getBrowserErrors();
56
- const browserThrewError = browserErrors.length > 0;
57
- const isFailure = err || browserThrewError;
55
+ const hasErrorLog = Logs_1.Logs.hasError(testInfo.runInfo.onlyFailOnBrowserError);
56
+ const isFailure = err || hasErrorLog;
58
57
  if (isFailure) {
59
58
  logTestsResult(false);
60
59
  if (err) {
61
60
  console.error(err);
62
61
  }
63
- if (browserThrewError) {
64
- console.log(new Error('The browser threw one or more error, see browser logs below.'));
62
+ if (hasErrorLog) {
63
+ console.log(new Error('The browser/server threw/logged one or more error, see logs below.'));
65
64
  }
66
65
  Logs_1.Logs.flush();
67
66
  process.exit(1);
package/dist/setup.d.ts CHANGED
@@ -17,12 +17,13 @@ export declare let urlBase: string;
17
17
  export declare const urlBaseChange: (url: string) => string;
18
18
  export { editFile, editFileRevert } from './editFile';
19
19
  declare function skip(reason: string): void;
20
- declare function run(cmd: string, { additionalTimeout, serverIsReadyMessage, serverIsReadyDelay, inspect, cwd, }?: {
20
+ declare function run(cmd: string, { additionalTimeout, serverIsReadyMessage, serverIsReadyDelay, inspect, cwd, onlyFailOnBrowserError, }?: {
21
21
  additionalTimeout?: number;
22
22
  serverIsReadyMessage?: string;
23
23
  serverIsReadyDelay?: number;
24
24
  inspect?: boolean;
25
25
  cwd?: string;
26
+ onlyFailOnBrowserError?: boolean;
26
27
  }): void;
27
28
  declare function autoRetry(test: () => void | Promise<void>, { timeout }?: {
28
29
  timeout?: number;
package/dist/setup.js CHANGED
@@ -37,7 +37,7 @@ function skip(reason) {
37
37
  exports.skip = skip;
38
38
  function run(cmd, {
39
39
  //baseUrl = '',
40
- additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect = utils_1.cliConfig.inspect, cwd, } = {}) {
40
+ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect = utils_1.cliConfig.inspect, cwd, onlyFailOnBrowserError = false, } = {}) {
41
41
  additionalTimeout += serverIsReadyDelay;
42
42
  const testInfo = (0, getCurrentTest_1.getCurrentTest)();
43
43
  testInfo.runInfo = {
@@ -48,6 +48,7 @@ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect
48
48
  serverIsReadyMessage,
49
49
  serverIsReadyDelay,
50
50
  inspect,
51
+ onlyFailOnBrowserError,
51
52
  };
52
53
  if (inspect) {
53
54
  Logs_1.Logs.flushEagerly = true;
@@ -90,7 +91,15 @@ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect
90
91
  function onConsole(msg) {
91
92
  const type = msg.type();
92
93
  Logs_1.Logs.add({
93
- logSource: type === 'error' ? 'Browser Error' : 'Browser Log',
94
+ logSource: (() => {
95
+ if (type === 'error') {
96
+ return 'Browser Error';
97
+ }
98
+ if (type === 'warning') {
99
+ return 'Browser Warning';
100
+ }
101
+ return 'Browser Log';
102
+ })(),
94
103
  logText: JSON.stringify({
95
104
  type,
96
105
  text: msg.text(),
@@ -1 +1,2 @@
1
- export declare function humanizeTime(milliseconds: number): string;
1
+ export { humanizeTime };
2
+ declare function humanizeTime(milliseconds: number): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {