@brillout/test-e2e 0.5.1 → 0.5.3

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) {
11
+ return false;
12
+ }
13
+ return config.tolerateError({ logSource, logText });
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,8 +15,8 @@ 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);
@@ -61,16 +61,7 @@ function flushLogs() {
61
61
  }
62
62
  function add({ logSource, logText, loggedAfterExit = false, }) {
63
63
  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
- })();
64
+ const isNotFailure = (0, isTolerateError_1.isTolerateError)({ logSource, logText });
74
65
  const logEntry = {
75
66
  logSource,
76
67
  logText,
@@ -1,6 +1,4 @@
1
1
  export { isParallelCI };
2
- export { abortIfParallelCI };
3
2
  export { getTestFilesForCurrentJob };
4
- declare function abortIfParallelCI(): void;
5
3
  declare function isParallelCI(): boolean;
6
4
  declare function getTestFilesForCurrentJob(): null | string[];
@@ -3,17 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getTestFilesForCurrentJob = exports.abortIfParallelCI = exports.isParallelCI = void 0;
6
+ exports.getTestFilesForCurrentJob = exports.isParallelCI = void 0;
7
7
  const utils_1 = require("./utils");
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const cwd = process.cwd();
11
- function abortIfParallelCI() {
12
- if (isParallelCI()) {
13
- process.exit(1);
14
- }
15
- }
16
- exports.abortIfParallelCI = abortIfParallelCI;
17
11
  function isParallelCI() {
18
12
  return getTestFilesForCurrentJob() !== null;
19
13
  }
package/dist/runAll.js CHANGED
@@ -71,6 +71,11 @@ async function runServerAndTests(browser, isSecondAttempt) {
71
71
  (0, utils_1.assert)(testInfo.startServer);
72
72
  (0, utils_1.assert)(testInfo.terminateServer);
73
73
  const isFinalAttempt = isSecondAttempt || !testInfo.runInfo.isFlaky;
74
+ const abortMaybe = () => {
75
+ if (isFinalAttempt && (0, parallel_ci_1.isParallelCI)()) {
76
+ process.exit(1);
77
+ }
78
+ };
74
79
  const page = await browser.newPage();
75
80
  testInfo.page = page;
76
81
  try {
@@ -78,6 +83,7 @@ async function runServerAndTests(browser, isSecondAttempt) {
78
83
  }
79
84
  catch (err) {
80
85
  logFailure(err, 'an error occurred while starting the server', isFinalAttempt);
86
+ abortMaybe();
81
87
  return false;
82
88
  }
83
89
  let success = await runTests(testInfo, isFinalAttempt);
@@ -93,11 +99,12 @@ async function runServerAndTests(browser, isSecondAttempt) {
93
99
  success = false;
94
100
  }
95
101
  }
96
- if (!success && !testInfo.runInfo.isFlaky)
97
- (0, parallel_ci_1.abortIfParallelCI)();
98
102
  if (success) {
99
103
  (0, logTestStatus_1.logPass)();
100
104
  }
105
+ else {
106
+ abortMaybe();
107
+ }
101
108
  Logs_1.Logs.clearLogs();
102
109
  return success;
103
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {