@brillout/test-e2e 0.5.10 → 0.5.12

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.
@@ -1,8 +1,13 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.isTolerateError = void 0;
4
7
  const getConfig_1 = require("../getConfig");
8
+ const strip_ansi_1 = __importDefault(require("strip-ansi"));
5
9
  function isTolerateError({ logSource, logText }) {
10
+ logText = (0, strip_ansi_1.default)(logText);
6
11
  if (tolerateError({ logSource, logText })) {
7
12
  return true;
8
13
  }
package/dist/Logs.d.ts CHANGED
@@ -5,7 +5,7 @@ export declare const Logs: {
5
5
  logErrorsAndWarnings: typeof logErrorsAndWarnings;
6
6
  clearLogs: typeof clearLogs;
7
7
  hasFailLogs: typeof hasFailLogs;
8
- logEagerly: boolean;
8
+ logEagerly: "all" | "logs";
9
9
  };
10
10
  export type { LogSource };
11
11
  declare type LogSource = 'stdout' | 'stderr' | 'Browser Error' | 'Browser Warning' | 'Browser Log' | 'Playwright' | 'run()' | 'run() failure' | 'test()' | 'Connection Error';
package/dist/Logs.js CHANGED
@@ -10,7 +10,7 @@ exports.Logs = {
10
10
  logErrorsAndWarnings,
11
11
  clearLogs,
12
12
  hasFailLogs,
13
- logEagerly: false,
13
+ logEagerly: 'all',
14
14
  };
15
15
  const utils_1 = require("./utils");
16
16
  const picocolors_1 = __importDefault(require("picocolors"));
@@ -72,7 +72,13 @@ function add({ logSource, logText, loggedAfterExit = false, }) {
72
72
  };
73
73
  logEntries.push(logEntry);
74
74
  if (exports.Logs.logEagerly) {
75
- printLog(logEntry);
75
+ let shouldLog = false;
76
+ if (exports.Logs.logEagerly === 'all')
77
+ shouldLog = true;
78
+ if (exports.Logs.logEagerly === 'logs' && logSource !== 'Playwright')
79
+ shouldLog = true;
80
+ if (shouldLog)
81
+ printLog(logEntry);
76
82
  }
77
83
  }
78
84
  function expectLog(logText, logFilter) {
@@ -117,7 +123,7 @@ function printLog(logEntry) {
117
123
  msg = msg.trim();
118
124
  let testInfoLabels = '';
119
125
  if (testInfo) {
120
- (0, utils_1.assert)(testInfo.runInfo);
126
+ (0, utils_1.assert)(testInfo.runInfo, testInfo);
121
127
  testInfoLabels = `[${testInfo.testName}][${testInfo.runInfo.cmd}]`;
122
128
  }
123
129
  console.log(`[${logTimestamp}]${testInfoLabels}[${logSourceLabel}] ${msg}`);
package/dist/page.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.page = void 0;
4
- const utils_1 = require("./utils");
5
4
  const getCurrentTest_1 = require("./getCurrentTest");
6
5
  const page = new Proxy({}, {
7
6
  get(_, prop) {
8
7
  const { page } = (0, getCurrentTest_1.getCurrentTest)();
9
- (0, utils_1.assert)(page);
8
+ if (!page)
9
+ throw new Error("`page` isn't available. Make sure to access `page` only inside test() calls. In particular, if test() is async, then make sure to await all asynchronous code executed by your async test().");
10
10
  return page[prop];
11
11
  },
12
12
  });
package/dist/run.js CHANGED
@@ -21,7 +21,10 @@ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect
21
21
  isFlaky,
22
22
  });
23
23
  if (inspect) {
24
- Logs_1.Logs.logEagerly = true;
24
+ Logs_1.Logs.logEagerly = 'all';
25
+ }
26
+ else if (utils_1.cliConfig.verbose) {
27
+ Logs_1.Logs.logEagerly = 'logs';
25
28
  }
26
29
  const testInfo = (0, getCurrentTest_1.getCurrentTest)();
27
30
  let runProcess = null;
package/dist/runAll.js CHANGED
@@ -27,7 +27,7 @@ async function runAll(filter) {
27
27
  (0, utils_1.assert)(hasFailedTestFile && hasFailLog);
28
28
  (0, utils_1.assert)(failedTestFiles.length > 0);
29
29
  throw new Error([
30
- 'Following test files failed, see all the logs printed above for more information.',
30
+ 'Following test files failed, see logs above for more information.',
31
31
  ...failedTestFiles.map((testFile) => ` ${testFile}`),
32
32
  ].join('\n'));
33
33
  }
@@ -1,4 +1,6 @@
1
- export declare const cliConfig: {
2
- debugEsbuild: boolean;
1
+ export { cliConfig };
2
+ declare const cliConfig: {
3
+ verbose: boolean;
3
4
  inspect: boolean;
5
+ debugEsbuild: boolean;
4
6
  };
@@ -1,9 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cliConfig = void 0;
4
- const cliArgs = process.argv.slice(2);
5
- exports.cliConfig = {
6
- debugEsbuild: cliArgs.includes('--debug-esbuild'),
4
+ const parseCli_1 = require("./parseCli");
5
+ (0, parseCli_1.prepare)();
6
+ const verbose = (0, parseCli_1.check)('--verbose');
7
+ const inspect = (0, parseCli_1.check)('--inspect');
8
+ const debugEsbuild = (0, parseCli_1.check)('--debug-esbuild');
9
+ (0, parseCli_1.validate)();
10
+ const cliConfig = {
11
+ verbose,
7
12
  // To inspect a specific test: `$ touch examples/some-example/INSPECT`
8
- inspect: cliArgs.includes('--inspect') || !!process.env.TEST_INSPECT,
13
+ inspect: inspect || !!process.env.TEST_INSPECT,
14
+ debugEsbuild,
9
15
  };
16
+ exports.cliConfig = cliConfig;
@@ -0,0 +1,6 @@
1
+ export { prepare };
2
+ export { check };
3
+ export { validate };
4
+ declare function prepare(): void;
5
+ declare function check(option: string): boolean;
6
+ declare function validate(): void;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validate = exports.check = exports.prepare = void 0;
4
+ let optionList;
5
+ const optionsKnown = [];
6
+ function prepare() {
7
+ optionList = process.argv.filter((w) => w.startsWith('--'));
8
+ }
9
+ exports.prepare = prepare;
10
+ function check(option) {
11
+ optionsKnown.push(option);
12
+ const val = optionList.includes(option);
13
+ if (val)
14
+ optionList = optionList.filter((s) => s !== option);
15
+ return val;
16
+ }
17
+ exports.check = check;
18
+ function validate() {
19
+ if (optionList.length > 0) {
20
+ throw new Error([
21
+ // prettier-ignore
22
+ `unknown options: ${optionList.join(' ')}`,
23
+ `known options: ${optionsKnown.join(' ')}`,
24
+ ].join('\n'));
25
+ }
26
+ }
27
+ exports.validate = validate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.5.10",
3
+ "version": "0.5.12",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {