@brillout/test-e2e 0.1.13 → 0.1.14

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(): 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,9 @@ 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() {
20
+ const logErrors = logEntries.filter(({ logSource, isExpectedError }) => (logSource === 'Browser Error' || logSource === 'Browser Warning' || logSource === 'stderr') && !isExpectedError);
21
+ return logErrors.length > 0;
21
22
  }
22
23
  function clear() {
23
24
  logEntries = [];
@@ -85,11 +86,13 @@ function colorize(logSource) {
85
86
  const { bold } = picocolors_1.default;
86
87
  if (logSource === 'stderr' || logSource === 'Browser Error' || logSource === 'Connection Error')
87
88
  return bold(picocolors_1.default.red(logSource));
89
+ if (logSource === 'Browser Warning')
90
+ return bold(picocolors_1.default.yellow(logSource));
88
91
  if (logSource === 'stdout' || logSource === 'Browser Log')
89
92
  return bold(picocolors_1.default.blue(logSource));
90
93
  if (logSource === 'Playwright')
91
94
  return bold(picocolors_1.default.magenta(logSource));
92
95
  if (logSource === 'run()' || logSource === 'test()')
93
- return bold(picocolors_1.default.yellow(logSource));
96
+ return bold(picocolors_1.default.cyan(logSource));
94
97
  (0, utils_1.assert)(false);
95
98
  }
@@ -1,3 +1,4 @@
1
+ /// <reference types="chai-subset" />
1
2
  export type { ChaiPlugin };
2
3
  export type { Expect };
3
4
  import type { use as chaiUse } from 'chai';
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();
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.js CHANGED
@@ -90,7 +90,15 @@ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect
90
90
  function onConsole(msg) {
91
91
  const type = msg.type();
92
92
  Logs_1.Logs.add({
93
- logSource: type === 'error' ? 'Browser Error' : 'Browser Log',
93
+ logSource: (() => {
94
+ if (type === 'error') {
95
+ return 'Browser Error';
96
+ }
97
+ if (type === 'warning') {
98
+ return 'Browser Warning';
99
+ }
100
+ return 'Browser Log';
101
+ })(),
94
102
  logText: JSON.stringify({
95
103
  type,
96
104
  text: msg.text(),
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.14",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {