@brillout/test-e2e 0.5.29 → 0.5.31

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.
Files changed (74) hide show
  1. package/bin.js +1 -1
  2. package/dist/Logs/isTolerateError.d.ts +2 -2
  3. package/dist/Logs/isTolerateError.js +5 -11
  4. package/dist/Logs.d.ts +2 -2
  5. package/dist/Logs.js +26 -32
  6. package/dist/TIMEOUTS.js +6 -9
  7. package/dist/autoRetry.js +5 -8
  8. package/dist/buildTs.js +10 -16
  9. package/dist/chai/JestChaiExpect.d.ts +1 -1
  10. package/dist/chai/JestChaiExpect.js +1 -5
  11. package/dist/chai/expect.d.ts +1 -1
  12. package/dist/chai/expect.js +4 -30
  13. package/dist/chai/types.d.ts +4 -4
  14. package/dist/chai/types.js +1 -2
  15. package/dist/cli.js +13 -18
  16. package/dist/editFile.js +18 -22
  17. package/dist/fetch.d.ts +2 -2
  18. package/dist/fetch.js +20 -16
  19. package/dist/findTestFiles.d.ts +1 -1
  20. package/dist/findTestFiles.js +6 -9
  21. package/dist/getBrowser.js +9 -12
  22. package/dist/getConfig.d.ts +1 -1
  23. package/dist/getConfig.js +14 -20
  24. package/dist/getCurrentTest.d.ts +1 -1
  25. package/dist/getCurrentTest.js +15 -21
  26. package/dist/index.d.ts +13 -13
  27. package/dist/index.js +14 -38
  28. package/dist/logError.js +3 -6
  29. package/dist/logSection.js +5 -11
  30. package/dist/logTestStatus.js +19 -25
  31. package/dist/page.js +3 -6
  32. package/dist/parallel-ci.js +8 -14
  33. package/dist/run.js +42 -45
  34. package/dist/runAll.d.ts +1 -1
  35. package/dist/runAll.js +61 -67
  36. package/dist/runCommandThatTerminates.js +6 -9
  37. package/dist/skip.js +3 -6
  38. package/dist/test.js +5 -8
  39. package/dist/testScreenshotFixture.js +42 -45
  40. package/dist/utils/assert.js +23 -26
  41. package/dist/utils/cliOptions.js +9 -12
  42. package/dist/utils/findFiles.d.ts +1 -1
  43. package/dist/utils/findFiles.js +13 -19
  44. package/dist/utils/fsWindowsBugWorkaround.js +2 -5
  45. package/dist/utils/genPromise.js +1 -5
  46. package/dist/utils/hasProp.d.ts +15 -0
  47. package/dist/utils/hasProp.js +50 -0
  48. package/dist/utils/humanizeTime.js +1 -4
  49. package/dist/utils/isArray.d.ts +1 -0
  50. package/dist/utils/isArray.js +4 -0
  51. package/dist/utils/isArrayOfStrings.d.ts +2 -0
  52. package/dist/utils/isArrayOfStrings.js +5 -0
  53. package/dist/utils/isCallable.js +1 -5
  54. package/dist/utils/isMinNodeVersion.js +4 -7
  55. package/dist/utils/isObject.d.ts +1 -1
  56. package/dist/utils/isObject.js +1 -5
  57. package/dist/utils/isObjectOfStrings.d.ts +2 -0
  58. package/dist/utils/isObjectOfStrings.js +5 -0
  59. package/dist/utils/isTTY.js +1 -4
  60. package/dist/utils/logProgress.js +4 -7
  61. package/dist/utils/parseCli.js +3 -6
  62. package/dist/utils/platform.js +6 -9
  63. package/dist/utils/projectInfo.js +1 -4
  64. package/dist/utils/runCommand.js +7 -10
  65. package/dist/utils/runCommandLongRunning.js +40 -32
  66. package/dist/utils/runCommandShortLived.js +7 -10
  67. package/dist/utils/sleep.js +1 -4
  68. package/dist/utils/trackLogs.d.ts +1 -1
  69. package/dist/utils/trackLogs.js +1 -1
  70. package/dist/utils.d.ts +16 -0
  71. package/dist/utils.js +16 -0
  72. package/package.json +3 -2
  73. package/dist/utils/index.d.ts +0 -15
  74. package/dist/utils/index.js +0 -31
package/bin.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require('./dist/cli.js')
2
+ import './dist/cli.js'
@@ -1,6 +1,6 @@
1
1
  export { isTolerateError };
2
- import type { LogSource } from '../Logs';
3
- declare type LogData = {
2
+ import type { LogSource } from '../Logs.js';
3
+ type LogData = {
4
4
  logSource: LogSource;
5
5
  logText: string;
6
6
  };
@@ -1,23 +1,17 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isTolerateError = void 0;
7
- const getConfig_1 = require("../getConfig");
8
- const strip_ansi_1 = __importDefault(require("strip-ansi"));
1
+ export { isTolerateError };
2
+ import { getConfig } from '../getConfig.js';
3
+ import stripAnsi from 'strip-ansi';
9
4
  function isTolerateError({ logSource, logText }) {
10
- logText = (0, strip_ansi_1.default)(logText);
5
+ logText = stripAnsi(logText);
11
6
  if (tolerateErrorBuiltIn({ logSource, logText })) {
12
7
  return true;
13
8
  }
14
- const config = (0, getConfig_1.getConfig)();
9
+ const config = getConfig();
15
10
  if (config.tolerateError?.({ logSource, logText })) {
16
11
  return true;
17
12
  }
18
13
  return false;
19
14
  }
20
- exports.isTolerateError = isTolerateError;
21
15
  function tolerateErrorBuiltIn({ logSource, logText }) {
22
16
  return [
23
17
  {
package/dist/Logs.d.ts CHANGED
@@ -8,8 +8,8 @@ export declare const Logs: {
8
8
  logEagerly: false | "all" | "logs";
9
9
  };
10
10
  export type { LogSource };
11
- declare type LogSource = 'stdout' | 'stderr' | 'Browser Error' | 'Browser Warning' | 'Browser Log' | 'Playwright' | 'run()' | 'run() failure' | 'test()' | 'Connection Error';
12
- declare type LogEntry = {
11
+ type LogSource = 'stdout' | 'stderr' | 'Browser Error' | 'Browser Warning' | 'Browser Log' | 'Playwright' | 'run()' | 'run() failure' | 'test()' | 'Connection Error';
12
+ type LogEntry = {
13
13
  logSource: LogSource;
14
14
  logText: string;
15
15
  logTimestamp: string;
package/dist/Logs.js CHANGED
@@ -1,10 +1,5 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Logs = exports.expectLog = void 0;
7
- exports.Logs = {
1
+ export { expectLog };
2
+ export const Logs = {
8
3
  add,
9
4
  flushLogs,
10
5
  logErrorsAndWarnings,
@@ -12,12 +7,12 @@ exports.Logs = {
12
7
  hasFailLogs,
13
8
  logEagerly: false,
14
9
  };
15
- const utils_1 = require("./utils");
16
- const picocolors_1 = __importDefault(require("@brillout/picocolors"));
17
- const getCurrentTest_1 = require("./getCurrentTest");
18
- const logSection_1 = require("./logSection");
19
- const isTolerateError_1 = require("./Logs/isTolerateError");
20
- const strip_ansi_1 = __importDefault(require("strip-ansi"));
10
+ import { assert, ensureNewTerminalLine, isWindows } from './utils.js';
11
+ import pc from '@brillout/picocolors';
12
+ import { getCurrentTestOptional } from './getCurrentTest.js';
13
+ import { logSection } from './logSection.js';
14
+ import { isTolerateError } from './Logs/isTolerateError.js';
15
+ import stripAnsi from 'strip-ansi';
21
16
  let logEntries = [];
22
17
  function hasFailLogs(failOnWarning) {
23
18
  const failLogs = getErrorLogs(failOnWarning);
@@ -30,7 +25,7 @@ function getErrorLogs(includeWarnings) {
30
25
  }
31
26
  const { logSource } = logEntry;
32
27
  // taskkill makes process exit with exit code `1` which makes npm emit logs on stderr
33
- if (logEntry.loggedAfterExit && (0, utils_1.isWindows)() && logSource === 'stderr') {
28
+ if (logEntry.loggedAfterExit && isWindows() && logSource === 'stderr') {
34
29
  return false;
35
30
  }
36
31
  if (logSource === 'run() failure') {
@@ -53,11 +48,11 @@ function logErrorsAndWarnings() {
53
48
  const errorAndWarningLogs = getErrorLogs(true);
54
49
  if (errorAndWarningLogs.length === 0)
55
50
  return;
56
- (0, logSection_1.logSection)('ERROR & WARNING LOGS');
51
+ logSection('ERROR & WARNING LOGS');
57
52
  errorAndWarningLogs.forEach((logEntry) => printLog(logEntry));
58
53
  }
59
54
  function flushLogs() {
60
- (0, logSection_1.logSection)('ALL LOGS');
55
+ logSection('ALL LOGS');
61
56
  logEntries.filter((logEntry) => !logEntry.loggedAfterExit).forEach((logEntry) => printLog(logEntry));
62
57
  logEntries = [];
63
58
  }
@@ -67,15 +62,15 @@ function add({ logSource, logText, loggedAfterExit = false, }) {
67
62
  logSource,
68
63
  logText,
69
64
  logTimestamp,
70
- isNotFailure: (0, isTolerateError_1.isTolerateError)({ logSource, logText }),
65
+ isNotFailure: isTolerateError({ logSource, logText }),
71
66
  loggedAfterExit,
72
67
  };
73
68
  logEntries.push(logEntry);
74
- if (exports.Logs.logEagerly) {
69
+ if (Logs.logEagerly) {
75
70
  let shouldLog = false;
76
- if (exports.Logs.logEagerly === 'all')
71
+ if (Logs.logEagerly === 'all')
77
72
  shouldLog = true;
78
- if (exports.Logs.logEagerly === 'logs' && logSource !== 'Playwright')
73
+ if (Logs.logEagerly === 'logs' && logSource !== 'Playwright')
79
74
  shouldLog = true;
80
75
  if (shouldLog)
81
76
  printLog(logEntry);
@@ -99,11 +94,10 @@ function expectLog(logText, logFilter) {
99
94
  throw new Error(`The following log was logged as expected, but it didn't match the logFilter() you provided: "${logText}"`);
100
95
  }
101
96
  }
102
- exports.expectLog = expectLog;
103
97
  function removeAnsi(logEntry) {
104
98
  const logEntryWithoutAnsi = {
105
99
  ...logEntry,
106
- logText: (0, strip_ansi_1.default)(logEntry.logText),
100
+ logText: stripAnsi(logEntry.logText),
107
101
  };
108
102
  return logEntryWithoutAnsi;
109
103
  }
@@ -117,9 +111,9 @@ function getTimestamp() {
117
111
  function printLog(logEntry) {
118
112
  const { logSource, logText, logTimestamp } = logEntry;
119
113
  let logSourceLabel = colorize(logSource);
120
- const testInfo = (0, getCurrentTest_1.getCurrentTestOptional)();
114
+ const testInfo = getCurrentTestOptional();
121
115
  // See https://github.com/nodejs/node/issues/8033#issuecomment-388323687
122
- if (!(0, utils_1.ensureNewTerminalLine)()) {
116
+ if (!ensureNewTerminalLine()) {
123
117
  console.log('');
124
118
  }
125
119
  let msg = logText;
@@ -130,30 +124,30 @@ function printLog(logEntry) {
130
124
  msg = msg.trim();
131
125
  let testInfoLabels = '';
132
126
  if (testInfo) {
133
- (0, utils_1.assert)(testInfo.runInfo, testInfo);
127
+ assert(testInfo.runInfo, testInfo);
134
128
  testInfoLabels = `[${testInfo.testName}][${testInfo.runInfo.cmd}]`;
135
129
  }
136
130
  console.log(`[${logTimestamp}]${testInfoLabels}[${logSourceLabel}] ${msg}`);
137
131
  }
138
132
  function colorize(logSource) {
139
- const { bold } = picocolors_1.default;
133
+ const { bold } = pc;
140
134
  if (logSource === 'stderr' ||
141
135
  logSource === 'Browser Error' ||
142
136
  logSource === 'Connection Error' ||
143
137
  logSource === 'run() failure') {
144
- return bold(picocolors_1.default.red(logSource));
138
+ return bold(pc.red(logSource));
145
139
  }
146
140
  if (logSource === 'Browser Warning') {
147
- return bold(picocolors_1.default.yellow(logSource));
141
+ return bold(pc.yellow(logSource));
148
142
  }
149
143
  if (logSource === 'stdout' || logSource === 'Browser Log') {
150
- return bold(picocolors_1.default.blue(logSource));
144
+ return bold(pc.blue(logSource));
151
145
  }
152
146
  if (logSource === 'Playwright') {
153
- return bold(picocolors_1.default.magenta(logSource));
147
+ return bold(pc.magenta(logSource));
154
148
  }
155
149
  if (logSource === 'run()' || logSource === 'test()') {
156
- return bold(picocolors_1.default.cyan(logSource));
150
+ return bold(pc.cyan(logSource));
157
151
  }
158
- (0, utils_1.assert)(false);
152
+ assert(false);
159
153
  }
package/dist/TIMEOUTS.js CHANGED
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TIMEOUT_PLAYWRIGHT = exports.TIMEOUT_AUTORETRY = exports.TIMEOUT_PROCESS_TERMINATION = exports.TIMEOUT_TEST_FUNCTION = exports.TIMEOUT_NPM_SCRIPT = void 0;
4
- const platform_1 = require("./utils/platform");
5
- exports.TIMEOUT_NPM_SCRIPT = 2 * 60 * 1000 * (!(0, platform_1.isCI)() ? 1 : (0, platform_1.isWindows)() ? 2 : 1);
6
- exports.TIMEOUT_TEST_FUNCTION = 60 * 1000 * (!(0, platform_1.isCI)() ? 1 : (0, platform_1.isWindows)() ? 5 : 3);
7
- exports.TIMEOUT_PROCESS_TERMINATION = 10 * 1000 * (!(0, platform_1.isCI)() ? 1 : (0, platform_1.isWindows)() ? 3 : !(0, platform_1.isLinux)() ? 3 : 1);
8
- exports.TIMEOUT_AUTORETRY = exports.TIMEOUT_TEST_FUNCTION / 2;
9
- exports.TIMEOUT_PLAYWRIGHT = exports.TIMEOUT_TEST_FUNCTION / 2;
1
+ import { isWindows, isLinux, isCI } from './utils/platform.js';
2
+ export const TIMEOUT_NPM_SCRIPT = 2 * 60 * 1000 * (!isCI() ? 1 : isWindows() ? 2 : 1);
3
+ export const TIMEOUT_TEST_FUNCTION = 60 * 1000 * (!isCI() ? 1 : isWindows() ? 5 : 3);
4
+ export const TIMEOUT_PROCESS_TERMINATION = 10 * 1000 * (!isCI() ? 1 : isWindows() ? 3 : !isLinux() ? 3 : 1);
5
+ export const TIMEOUT_AUTORETRY = TIMEOUT_TEST_FUNCTION / 2;
6
+ export const TIMEOUT_PLAYWRIGHT = TIMEOUT_TEST_FUNCTION / 2;
package/dist/autoRetry.js CHANGED
@@ -1,9 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.autoRetry = void 0;
4
- const TIMEOUTS_1 = require("./TIMEOUTS");
5
- const utils_1 = require("./utils");
6
- async function autoRetry(test, { timeout = TIMEOUTS_1.TIMEOUT_AUTORETRY } = {}) {
1
+ export { autoRetry };
2
+ import { TIMEOUT_AUTORETRY } from './TIMEOUTS.js';
3
+ import { sleep } from './utils.js';
4
+ async function autoRetry(test, { timeout = TIMEOUT_AUTORETRY } = {}) {
7
5
  const period = 100;
8
6
  const numberOfTries = timeout / period;
9
7
  let i = 0;
@@ -18,7 +16,6 @@ async function autoRetry(test, { timeout = TIMEOUTS_1.TIMEOUT_AUTORETRY } = {})
18
16
  throw err;
19
17
  }
20
18
  }
21
- await (0, utils_1.sleep)(period);
19
+ await sleep(period);
22
20
  }
23
21
  }
24
- exports.autoRetry = autoRetry;
package/dist/buildTs.js CHANGED
@@ -1,16 +1,11 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.sourceMaps = exports.buildTs = void 0;
7
- const esbuild_1 = __importDefault(require("esbuild"));
8
- const fs_1 = __importDefault(require("fs"));
9
- const utils_1 = require("./utils");
1
+ export { buildTs };
2
+ export { sourceMaps };
3
+ import esbuild from 'esbuild';
4
+ import fs from 'fs';
5
+ import { cliOptions } from './utils.js';
10
6
  const sourceMaps = {};
11
- exports.sourceMaps = sourceMaps;
12
7
  async function buildTs(entry, outfile) {
13
- await esbuild_1.default.build({
8
+ await esbuild.build({
14
9
  platform: 'node',
15
10
  entryPoints: [entry],
16
11
  sourcemap: true,
@@ -24,15 +19,14 @@ async function buildTs(entry, outfile) {
24
19
  });
25
20
  {
26
21
  const sourceMapFile = `${outfile}.map`;
27
- sourceMaps[outfile] = fs_1.default.readFileSync(sourceMapFile, 'utf8');
28
- fs_1.default.unlinkSync(sourceMapFile);
22
+ sourceMaps[outfile] = fs.readFileSync(sourceMapFile, 'utf8');
23
+ fs.unlinkSync(sourceMapFile);
29
24
  }
30
25
  const clean = () => {
31
- if (utils_1.cliOptions.debugEsbuild) {
26
+ if (cliOptions.debugEsbuild) {
32
27
  return;
33
28
  }
34
- fs_1.default.unlinkSync(`${outfile}`);
29
+ fs.unlinkSync(`${outfile}`);
35
30
  };
36
31
  return clean;
37
32
  }
38
- exports.buildTs = buildTs;
@@ -1,2 +1,2 @@
1
- import type { ChaiPlugin } from './types';
1
+ import type { ChaiPlugin } from './types.js';
2
2
  export declare const JestChaiExpect: ChaiPlugin;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JestChaiExpect = void 0;
4
1
  // Copied from https://github.com/vitest-dev/vitest/blob/f3524602ccc678badaae6bc5c3945008d8cfd82a/packages/vitest/src/integrations/chai/jest-expect.ts
5
- const JestChaiExpect = (chai, utils) => {
2
+ export const JestChaiExpect = (chai, utils) => {
6
3
  function def(name, fn) {
7
4
  utils.addMethod(chai.Assertion.prototype, name, fn);
8
5
  }
@@ -24,4 +21,3 @@ const JestChaiExpect = (chai, utils) => {
24
21
  this.assert(!obj, 'expected #{this} to be falsy', 'expected #{this} to not be falsy', obj);
25
22
  });
26
23
  };
27
- exports.JestChaiExpect = JestChaiExpect;
@@ -1,2 +1,2 @@
1
- import type { Expect } from './types';
1
+ import type { Expect } from './types.js';
2
2
  export declare const expect: Expect;
@@ -1,30 +1,4 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.expect = void 0;
27
- const JestChaiExpect_1 = require("./JestChaiExpect");
28
- const chai = __importStar(require("chai"));
29
- chai.use(JestChaiExpect_1.JestChaiExpect);
30
- exports.expect = chai.expect;
1
+ import { JestChaiExpect } from './JestChaiExpect.js';
2
+ import * as chai from 'chai';
3
+ chai.use(JestChaiExpect);
4
+ export const expect = chai.expect;
@@ -1,9 +1,9 @@
1
1
  export type { ChaiPlugin };
2
2
  export type { Expect };
3
3
  import type { use as chaiUse } from 'chai';
4
- declare type FirstFunctionArgument<T> = T extends (arg: infer A) => unknown ? A : never;
5
- declare type ChaiPlugin = FirstFunctionArgument<typeof chaiUse>;
6
- declare type Assertion = Chai.Assertion & {
4
+ type FirstFunctionArgument<T> = T extends (arg: infer A) => unknown ? A : never;
5
+ type ChaiPlugin = FirstFunctionArgument<typeof chaiUse>;
6
+ type Assertion = Chai.Assertion & {
7
7
  not: Assertion;
8
8
  toContain: Assertion['contain'];
9
9
  toMatch: Assertion['match'];
@@ -12,4 +12,4 @@ declare type Assertion = Chai.Assertion & {
12
12
  toBeTruthy(): void;
13
13
  toBee: Assertion['equal'];
14
14
  };
15
- declare type Expect = (value: any) => Assertion;
15
+ type Expect = (value: any) => Assertion;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/dist/cli.js CHANGED
@@ -1,23 +1,18 @@
1
- "use strict";
2
1
  /* Track down log origins
3
2
  import './utils/trackLogs'
4
3
  //*/
5
- var __importDefault = (this && this.__importDefault) || function (mod) {
6
- return (mod && mod.__esModule) ? mod : { "default": mod };
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const source_map_support_1 = __importDefault(require("source-map-support"));
10
- const utils_1 = require("./utils");
11
- const runAll_1 = require("./runAll");
12
- const buildTs_1 = require("./buildTs");
13
- const Logs_1 = require("./Logs");
4
+ import sourceMapSupport from 'source-map-support';
5
+ import { assert, findFilesParseCliArgs, fsWindowsBugWorkaroundPrefix } from './utils.js';
6
+ import { runAll } from './runAll.js';
7
+ import { sourceMaps } from './buildTs.js';
8
+ import { Logs } from './Logs.js';
14
9
  initSourceMap();
15
10
  initPromiseRejectionHandler();
16
11
  initUserExitHandler();
17
12
  cli();
18
13
  function cli() {
19
- const filter = (0, utils_1.findFilesParseCliArgs)();
20
- (0, runAll_1.runAll)(filter);
14
+ const filter = findFilesParseCliArgs();
15
+ runAll(filter);
21
16
  }
22
17
  function initPromiseRejectionHandler() {
23
18
  process.on('unhandledRejection', function (err) {
@@ -27,31 +22,31 @@ function initPromiseRejectionHandler() {
27
22
  }
28
23
  function initUserExitHandler() {
29
24
  process.on('SIGINT', function () {
30
- Logs_1.Logs.flushLogs();
25
+ Logs.flushLogs();
31
26
  });
32
27
  }
33
28
  // This mechanism seems necessary for the source map to apply for errors that happen a long time after the build file, which contains the inline source map, is removed.
34
29
  // - The much simpler alternative used by Vike doesn't seem to work: https://github.com/brillout/vite-plugin-ssr/blob/77b1b0e8b6c1ed4efe3e3039f7c0b23a00651663/vite-plugin-ssr/node/plugin/plugins/importUserCode/v1-design/transpileAndLoadFile.ts#L200-L208
35
30
  // - Failed attempt to make the simpler alternative work: https://github.com/brillout/test-e2e/commit/681abd19459b8c7d3ade9363ba32be86e3fdcb53
36
31
  function initSourceMap() {
37
- source_map_support_1.default.install({
32
+ sourceMapSupport.install({
38
33
  retrieveSourceMap: function (source) {
39
- const prefix = utils_1.fsWindowsBugWorkaroundPrefix;
34
+ const prefix = fsWindowsBugWorkaroundPrefix;
40
35
  if (source.startsWith(prefix)) {
41
36
  source = source.slice(prefix.length);
42
37
  if (process.platform == 'win32') {
43
- (0, utils_1.assert)(source.startsWith('/'));
38
+ assert(source.startsWith('/'));
44
39
  source = source.slice(1);
45
40
  source = source.split('/').join('\\');
46
41
  }
47
42
  }
48
- let sourceMap = buildTs_1.sourceMaps[source];
43
+ let sourceMap = sourceMaps[source];
49
44
  if (sourceMap) {
50
45
  return {
51
46
  map: sourceMap,
52
47
  };
53
48
  }
54
- (0, utils_1.assert)(!source.endsWith('.test.mjs'), { source, sourceMapsKeys: Object.keys(buildTs_1.sourceMaps) });
49
+ assert(!source.endsWith('.test.mjs'), { source, sourceMapsKeys: Object.keys(sourceMaps) });
55
50
  return null;
56
51
  },
57
52
  });
package/dist/editFile.js CHANGED
@@ -1,49 +1,45 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.editFileAssertReverted = exports.editFileRevert = exports.editFile = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const utils_1 = require("./utils");
10
- const getCurrentTest_1 = require("./getCurrentTest");
1
+ export { editFile };
2
+ export { editFileRevert };
3
+ export { editFileAssertReverted };
4
+ import fs from 'fs';
5
+ import path from 'path';
6
+ import { assert } from './utils.js';
7
+ import { getCurrentTest } from './getCurrentTest.js';
8
+ import { createRequire } from 'module';
9
+ const require_ = createRequire(import.meta.url);
11
10
  const filesContentOriginal = {};
12
11
  function editFile(filePathRelative, replacer) {
13
12
  const filePath = getFilePath(filePathRelative);
14
- const fileContent = fs_1.default.readFileSync(filePath, 'utf8');
13
+ const fileContent = fs.readFileSync(filePath, 'utf8');
15
14
  if (!(filePath in filesContentOriginal)) {
16
15
  filesContentOriginal[filePath] = fileContent;
17
16
  }
18
17
  const fileContentNew = replacer(fileContent);
19
18
  // expect(fileContentNew).not.toBe(fileContent)
20
- (0, utils_1.assert)(fileContentNew !== fileContent);
21
- fs_1.default.writeFileSync(filePath, fileContentNew);
19
+ assert(fileContentNew !== fileContent);
20
+ fs.writeFileSync(filePath, fileContentNew);
22
21
  }
23
- exports.editFile = editFile;
24
22
  function editFileRevert() {
25
23
  Object.entries(filesContentOriginal).forEach(([filePath, fileContent]) => {
26
- fs_1.default.writeFileSync(filePath, fileContent);
24
+ fs.writeFileSync(filePath, fileContent);
27
25
  delete filesContentOriginal[filePath];
28
26
  });
29
27
  }
30
- exports.editFileRevert = editFileRevert;
31
28
  function editFileAssertReverted() {
32
29
  const filesDirty = Object.keys(filesContentOriginal);
33
30
  try {
34
31
  // expect(filesDirty).toEqual([])
35
- (0, utils_1.assert)(filesDirty.length === 0);
32
+ assert(filesDirty.length === 0);
36
33
  }
37
34
  catch (err) {
38
35
  editFileRevert();
39
36
  throw err;
40
37
  }
41
- (0, utils_1.assert)(filesDirty.length === 0);
38
+ assert(filesDirty.length === 0);
42
39
  }
43
- exports.editFileAssertReverted = editFileAssertReverted;
44
40
  function getFilePath(filePathRelative) {
45
- const { testFile } = (0, getCurrentTest_1.getCurrentTest)();
46
- const cwd = path_1.default.dirname(testFile);
47
- const filePath = require.resolve(filePathRelative, { paths: [cwd] });
41
+ const { testFile } = getCurrentTest();
42
+ const cwd = path.dirname(testFile);
43
+ const filePath = require_.resolve(filePathRelative, { paths: [cwd] });
48
44
  return filePath;
49
45
  }
package/dist/fetch.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { fetch };
2
2
  export { fetchHtml };
3
- import fetch_ from 'node-fetch';
3
+ import type { RequestInfo, RequestInit, Response } from 'node-fetch';
4
4
  declare function fetchHtml(pathname: string): Promise<string>;
5
- declare function fetch(...args: Parameters<typeof fetch_>): Promise<import("node-fetch").Response>;
5
+ declare function fetch(url: RequestInfo, init?: RequestInit): Promise<Response>;
package/dist/fetch.js CHANGED
@@ -1,30 +1,34 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.fetchHtml = exports.fetch = void 0;
7
- const getCurrentTest_1 = require("./getCurrentTest");
8
- const node_fetch_1 = __importDefault(require("node-fetch"));
9
- const Logs_1 = require("./Logs");
1
+ export { fetch };
2
+ export { fetchHtml };
3
+ import { getServerUrl } from './getCurrentTest.js';
4
+ import fetch_ from 'node-fetch';
5
+ import { Logs } from './Logs.js';
10
6
  async function fetchHtml(pathname) {
11
- const response = await fetch((0, getCurrentTest_1.getServerUrl)() + pathname);
7
+ const response = await fetch(getServerUrl() + pathname);
12
8
  const html = await response.text();
13
9
  return html;
14
10
  }
15
- exports.fetchHtml = fetchHtml;
16
- async function fetch(...args) {
11
+ async function fetch(url, init) {
17
12
  try {
18
- return await (0, node_fetch_1.default)(...args);
13
+ // @ts-ignore
14
+ //
15
+ // I don't know why but [transition to ESM](https://github.com/brillout/test-e2e/commit/9b0822a4f5bf787de5a150173f3eeffcfa7ebc5c) broke the default importing of the node-fetch types.
16
+ //
17
+ // The following used to work but doens't anymore:
18
+ // ```js
19
+ // async function fetch(...args: Parameters<typeof fetch_>) {
20
+ // // ...
21
+ // }
22
+ // ```
23
+ return await fetch_(url, init);
19
24
  }
20
25
  catch (err) {
21
- Logs_1.Logs.add({
26
+ Logs.add({
22
27
  logSource: 'Connection Error',
23
- logText: `Couldn't connect to \`${args[0]}\`. Args: \`${JSON.stringify(args.slice(1))}\`. Err: \`${
28
+ logText: `Couldn't connect to \`${url}\`. Args: \`${JSON.stringify(init)}\`. Err: \`${
24
29
  // @ts-ignore
25
30
  err.message}\``,
26
31
  });
27
32
  throw new Error("Couldn't connect to server. See `Connection Error` log for more details.");
28
33
  }
29
34
  }
30
- exports.fetch = fetch;
@@ -1,3 +1,3 @@
1
1
  export { findTestFiles };
2
- import { FindFilter } from './utils';
2
+ import { FindFilter } from './utils.js';
3
3
  declare function findTestFiles(findFilter: null | FindFilter): Promise<string[]>;
@@ -1,24 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findTestFiles = void 0;
4
- const utils_1 = require("./utils");
5
- const parallel_ci_1 = require("./parallel-ci");
1
+ export { findTestFiles };
2
+ import { filterFiles, findFiles } from './utils.js';
3
+ import { getTestFilesForCurrentJob } from './parallel-ci.js';
6
4
  // Unit tests `**/*.spec.*` are handled by Vitest
7
5
  const testFilenamePattern = '**/*.test.ts';
8
6
  async function findTestFiles(findFilter) {
9
7
  const testFilesAll = await findTestFilesAll();
10
- const testFiles = (0, utils_1.filterFiles)(testFilesAll, findFilter);
8
+ const testFiles = filterFiles(testFilesAll, findFilter);
11
9
  return testFiles;
12
10
  }
13
- exports.findTestFiles = findTestFiles;
14
11
  async function findTestFilesAll() {
15
12
  {
16
- const testFiles = (0, parallel_ci_1.getTestFilesForCurrentJob)();
13
+ const testFiles = getTestFilesForCurrentJob();
17
14
  if (testFiles)
18
15
  return testFiles;
19
16
  }
20
17
  {
21
- const testFiles = (0, utils_1.findFiles)(testFilenamePattern);
18
+ const testFiles = findFiles(testFilenamePattern);
22
19
  return testFiles;
23
20
  }
24
21
  }
@@ -1,21 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBrowser = void 0;
4
- const playwright_chromium_1 = require("playwright-chromium");
5
- const Logs_1 = require("./Logs");
6
- const utils_1 = require("./utils");
1
+ export { getBrowser };
2
+ import { chromium } from 'playwright-chromium';
3
+ import { Logs } from './Logs.js';
4
+ import { assert, logProgress } from './utils.js';
7
5
  let browser;
8
6
  async function getBrowser() {
9
7
  if (!browser) {
10
- const done = (0, utils_1.logProgress)('Launch Browser');
11
- browser = await playwright_chromium_1.chromium.launch({
8
+ const done = logProgress('Launch Browser');
9
+ browser = await chromium.launch({
12
10
  headless: true,
13
11
  logger: {
14
12
  isEnabled: () => true,
15
13
  log: (name, _severity, message, args, _hint, ...rest) => {
16
- (0, utils_1.assert)(args.length === 0);
17
- (0, utils_1.assert)(rest.length === 0);
18
- Logs_1.Logs.add({
14
+ assert(args.length === 0);
15
+ assert(rest.length === 0);
16
+ Logs.add({
19
17
  logSource: 'Playwright',
20
18
  logText: `${name} ${message}`,
21
19
  });
@@ -26,4 +24,3 @@ async function getBrowser() {
26
24
  }
27
25
  return browser;
28
26
  }
29
- exports.getBrowser = getBrowser;