@brillout/test-e2e 0.5.2 → 0.5.4

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.
@@ -0,0 +1,7 @@
1
+ export { isTolerateError };
2
+ import type { LogSource } from '../Logs';
3
+ declare type LogData = {
4
+ logSource: LogSource;
5
+ logText: string;
6
+ };
7
+ declare function isTolerateError({ logSource, logText }: LogData): boolean;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTolerateError = void 0;
4
+ const getConfig_1 = require("../getConfig");
5
+ function isTolerateError({ logSource, logText }) {
6
+ if (tolerateError({ logSource, logText })) {
7
+ return true;
8
+ }
9
+ const config = (0, getConfig_1.getConfig)();
10
+ if (config.tolerateError?.({ logSource, logText })) {
11
+ return true;
12
+ }
13
+ return false;
14
+ }
15
+ exports.isTolerateError = isTolerateError;
16
+ function tolerateError({ logSource, logText }) {
17
+ return isFetchExperimentalWarning() || isTerminationEPIPE();
18
+ function isFetchExperimentalWarning() {
19
+ return (logSource === 'stderr' &&
20
+ logText.includes('ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time'));
21
+ }
22
+ /* Suppress:
23
+ ```
24
+ [16:00:26.335][/examples/i18n-v1][npm run dev][run()] Terminate server.
25
+ [16:00:26.342][/examples/i18n-v1][npm run dev][stderr] The service was stopped: write EPIPE
26
+ [16:00:26.342][/examples/i18n-v1][npm run dev][run()] Process termination. (Nominal, exit code: null.)
27
+ ```
28
+ */
29
+ function isTerminationEPIPE() {
30
+ return logSource === 'stderr' && logText.includes('The service was stopped: write EPIPE');
31
+ }
32
+ }
package/dist/Logs.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare const Logs: {
7
7
  hasFailLogs: typeof hasFailLogs;
8
8
  logEagerly: boolean;
9
9
  };
10
+ export type { LogSource };
10
11
  declare type LogSource = 'stdout' | 'stderr' | 'Browser Error' | 'Browser Warning' | 'Browser Log' | 'Playwright' | 'run()' | 'run() failure' | 'test()' | 'Connection Error';
11
12
  declare type LogEntry = {
12
13
  logSource: LogSource;
package/dist/Logs.js CHANGED
@@ -15,20 +15,21 @@ exports.Logs = {
15
15
  const utils_1 = require("./utils");
16
16
  const picocolors_1 = __importDefault(require("picocolors"));
17
17
  const getCurrentTest_1 = require("./getCurrentTest");
18
- const getConfig_1 = require("./getConfig");
19
18
  const logSection_1 = require("./logSection");
19
+ const isTolerateError_1 = require("./Logs/isTolerateError");
20
20
  let logEntries = [];
21
21
  function hasFailLogs(failOnWarning) {
22
22
  const failLogs = getErrorLogs(failOnWarning);
23
23
  return failLogs.length > 0;
24
24
  }
25
25
  function getErrorLogs(includeWarnings) {
26
- const errorLogs = logEntries.filter(({ logSource, isNotFailure, loggedAfterExit }) => {
27
- if (isNotFailure) {
26
+ const errorLogs = logEntries.filter((logEntry) => {
27
+ if (logEntry.isNotFailure) {
28
28
  return false;
29
29
  }
30
+ const { logSource } = logEntry;
30
31
  // taskkill makes process exit with exit code `1` which makes npm emit logs on stderr
31
- if (loggedAfterExit && (0, utils_1.isWindows)() && logSource === 'stderr') {
32
+ if (logEntry.loggedAfterExit && (0, utils_1.isWindows)() && logSource === 'stderr') {
32
33
  return false;
33
34
  }
34
35
  if (logSource === 'run() failure') {
@@ -61,21 +62,11 @@ function flushLogs() {
61
62
  }
62
63
  function add({ logSource, logText, loggedAfterExit = false, }) {
63
64
  const logTimestamp = getTimestamp();
64
- const isNotFailure = (() => {
65
- const config = (0, getConfig_1.getConfig)();
66
- if (!config.tolerateError) {
67
- return false;
68
- }
69
- return config.tolerateError({
70
- logSource,
71
- logText,
72
- });
73
- })();
74
65
  const logEntry = {
75
66
  logSource,
76
67
  logText,
77
68
  logTimestamp,
78
- isNotFailure,
69
+ isNotFailure: (0, isTolerateError_1.isTolerateError)({ logSource, logText }),
79
70
  loggedAfterExit,
80
71
  };
81
72
  logEntries.push(logEntry);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {