@brillout/test-e2e 0.1.6 → 0.1.8

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/buildTs.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export { buildTs };
2
+ export { sourceMaps };
3
+ declare const sourceMaps: Record<string, string>;
2
4
  declare function buildTs(entry: string, outfile: string): Promise<() => void>;
package/dist/buildTs.js CHANGED
@@ -3,10 +3,12 @@ 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.buildTs = void 0;
6
+ exports.sourceMaps = exports.buildTs = void 0;
7
7
  const esbuild_1 = __importDefault(require("esbuild"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const utils_1 = require("./utils");
10
+ const sourceMaps = {};
11
+ exports.sourceMaps = sourceMaps;
10
12
  async function buildTs(entry, outfile) {
11
13
  await esbuild_1.default.build({
12
14
  platform: 'node',
@@ -20,12 +22,16 @@ async function buildTs(entry, outfile) {
20
22
  external: ['./node_modules/*', '@brillout/test-e2e'],
21
23
  minify: false,
22
24
  });
25
+ {
26
+ const sourceMapFile = `${outfile}.map`;
27
+ sourceMaps[outfile] = fs_1.default.readFileSync(sourceMapFile, 'utf8');
28
+ fs_1.default.unlinkSync(sourceMapFile);
29
+ }
23
30
  const clean = () => {
24
31
  if (utils_1.cliConfig.debugEsbuild) {
25
32
  return;
26
33
  }
27
34
  fs_1.default.unlinkSync(`${outfile}`);
28
- fs_1.default.unlinkSync(`${outfile}.map`);
29
35
  };
30
36
  return clean;
31
37
  }
package/dist/cli.d.ts CHANGED
@@ -1 +1 @@
1
- import 'source-map-support/register';
1
+ export {};
package/dist/cli.js CHANGED
@@ -1,9 +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
- // @ts-ignore
4
- require("source-map-support/register");
6
+ const source_map_support_1 = __importDefault(require("source-map-support"));
5
7
  const utils_1 = require("./utils");
6
8
  const runTestSuites_1 = require("./runTestSuites");
9
+ const buildTs_1 = require("./buildTs");
10
+ initSourceMap();
7
11
  initPromiseRejectionHandler();
8
12
  cli();
9
13
  function cli() {
@@ -16,3 +20,20 @@ function initPromiseRejectionHandler() {
16
20
  process.exit(1);
17
21
  });
18
22
  }
23
+ function initSourceMap() {
24
+ source_map_support_1.default.install({
25
+ retrieveSourceMap: function (source) {
26
+ const prefix = utils_1.fsWindowsBugWorkaroundPrefix;
27
+ if (source.startsWith(prefix)) {
28
+ source = source.slice(prefix.length);
29
+ }
30
+ let sourceMap = buildTs_1.sourceMaps[source];
31
+ if (sourceMap) {
32
+ return {
33
+ map: sourceMap,
34
+ };
35
+ }
36
+ return null;
37
+ },
38
+ });
39
+ }
@@ -12,11 +12,11 @@ declare type TestInfo = {
12
12
  runInfo?: {
13
13
  cmd: string;
14
14
  cwd: string;
15
- testTimeout: number;
15
+ testFunctionTimeout: number;
16
16
  additionalTimeout: number;
17
17
  serverIsReadyMessage?: string;
18
18
  serverIsReadyDelay: number;
19
- debug: boolean;
19
+ inspect: boolean;
20
20
  };
21
21
  hasStartedRunning?: boolean;
22
22
  skipped?: string;
@@ -16,7 +16,7 @@ async function runTestSuites(filter) {
16
16
  const clean = await (0, buildTs_1.buildTs)(testFile, testFileJs);
17
17
  (0, getCurrentTest_1.setCurrentTest)(testFile);
18
18
  try {
19
- await import(workaroundBug(testFileJs));
19
+ await import((0, utils_1.fsWindowsBugWorkaround)(testFileJs));
20
20
  }
21
21
  finally {
22
22
  clean();
@@ -28,7 +28,3 @@ async function runTestSuites(filter) {
28
28
  await browser.close();
29
29
  }
30
30
  exports.runTestSuites = runTestSuites;
31
- // https://stackoverflow.com/questions/69665780/error-err-unsupported-esm-url-scheme-only-file-and-data-urls-are-supported-by/70057245#70057245
32
- function workaroundBug(testFileJs) {
33
- return `file://${testFileJs}`;
34
- }
package/dist/runTests.js CHANGED
@@ -42,10 +42,10 @@ async function runTests(browser) {
42
42
  logSource: 'test()',
43
43
  logText: testDesc,
44
44
  });
45
- const done = (0, utils_1.logProgress)(` | [test] ${testDesc}`);
45
+ const done = (0, utils_1.logProgress)(`| [test] ${testDesc}`);
46
46
  let err;
47
47
  try {
48
- await runTest(testFn, testInfo.runInfo.testTimeout);
48
+ await runTest(testFn, testInfo.runInfo.testFunctionTimeout);
49
49
  }
50
50
  catch (err_) {
51
51
  err = err_;
@@ -75,7 +75,7 @@ async function runTests(browser) {
75
75
  logTestsResult(true);
76
76
  }
77
77
  exports.runTests = runTests;
78
- function runTest(testFn, testTimeout) {
78
+ function runTest(testFn, testFunctionTimeout) {
79
79
  let resolve;
80
80
  let reject;
81
81
  const promise = new Promise((resolve_, reject_) => {
@@ -83,8 +83,8 @@ function runTest(testFn, testTimeout) {
83
83
  reject = reject_;
84
84
  });
85
85
  const timeout = setTimeout(() => {
86
- reject(new Error(`[test] Timeout after ${(0, utils_1.humanizeTime)(testTimeout)}`));
87
- }, testTimeout);
86
+ reject(new Error(`[test] Timeout after ${(0, utils_1.humanizeTime)(testFunctionTimeout)}`));
87
+ }, testFunctionTimeout);
88
88
  const ret = testFn();
89
89
  (async () => {
90
90
  try {
@@ -102,9 +102,9 @@ function runTest(testFn, testTimeout) {
102
102
  }
103
103
  function logTestsResult(success) {
104
104
  const testInfo = (0, getCurrentTest_1.getCurrentTest)();
105
- const passStyle = (t) => (0, picocolors_1.white)((0, picocolors_1.bgGreen)(t));
106
- const failStyle = (t) => (0, picocolors_1.white)((0, picocolors_1.bgRed)(t));
107
- const skipStyle = (t) => (0, picocolors_1.white)((0, picocolors_1.bgYellow)(t));
105
+ const passStyle = (t) => (0, picocolors_1.bold)((0, picocolors_1.white)((0, picocolors_1.bgGreen)(t)));
106
+ const failStyle = (t) => (0, picocolors_1.bold)((0, picocolors_1.white)((0, picocolors_1.bgRed)(t)));
107
+ const skipStyle = (t) => (0, picocolors_1.bold)((0, picocolors_1.white)((0, picocolors_1.bgYellow)(t)));
108
108
  if (success) {
109
109
  (0, utils_1.assert)(!testInfo.skipped);
110
110
  console.log(`${passStyle('PASS')} ${testInfo.testFile}`);
package/dist/setup.d.ts CHANGED
@@ -17,11 +17,11 @@ export declare let urlBase: string;
17
17
  export declare const urlBaseChange: (url: string) => string;
18
18
  export { editFile, editFileRevert } from './editFile';
19
19
  declare function skip(reason: string): void;
20
- declare function run(cmd: string, { additionalTimeout, serverIsReadyMessage, serverIsReadyDelay, debug, cwd, }?: {
20
+ declare function run(cmd: string, { additionalTimeout, serverIsReadyMessage, serverIsReadyDelay, inspect, cwd, }?: {
21
21
  additionalTimeout?: number;
22
22
  serverIsReadyMessage?: string;
23
23
  serverIsReadyDelay?: number;
24
- debug?: boolean;
24
+ inspect?: boolean;
25
25
  cwd?: string;
26
26
  }): void;
27
27
  declare function autoRetry(test: () => void | Promise<void>, { timeout }?: {
package/dist/setup.js CHANGED
@@ -26,10 +26,10 @@ var editFile_2 = require("./editFile");
26
26
  Object.defineProperty(exports, "editFile", { enumerable: true, get: function () { return editFile_2.editFile; } });
27
27
  Object.defineProperty(exports, "editFileRevert", { enumerable: true, get: function () { return editFile_2.editFileRevert; } });
28
28
  const TIMEOUT_NPM_SCRIPT = 30 * 1000 * (!isGithubAction() ? 1 : isLinux() ? 1 : isWindows() ? 5 : 4);
29
- const TIMEOUT_JEST = 30 * 1000 * (!isGithubAction() ? 1 : isWindows() ? 10 : 6);
29
+ const TIMEOUT_TEST_FUNCTION = 30 * 1000 * (!isGithubAction() ? 1 : isWindows() ? 10 : 6);
30
30
  const TIMEOUT_AUTORETRY = 10 * 1000 * (!isGithubAction() || isLinux() ? 1 : 20); // TODO reduce `20`
31
31
  const TIMEOUT_PROCESS_TERMINATION = 10 * 1000 * (!isGithubAction() ? 1 : isLinux() ? 1 : 4);
32
- const TIMEOUT_PLAYWRIGHT = TIMEOUT_JEST;
32
+ const TIMEOUT_PLAYWRIGHT = 20 * 1000 * (!isGithubAction() ? 1 : isWindows() ? 5 : 4);
33
33
  function skip(reason) {
34
34
  const testInfo = (0, getCurrentTest_1.getCurrentTest)();
35
35
  testInfo.skipped = reason;
@@ -37,19 +37,19 @@ function skip(reason) {
37
37
  exports.skip = skip;
38
38
  function run(cmd, {
39
39
  //baseUrl = '',
40
- additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, debug = utils_1.cliConfig.debug, cwd, } = {}) {
40
+ additionalTimeout = 0, serverIsReadyMessage, serverIsReadyDelay = 1000, inspect = utils_1.cliConfig.inspect, cwd, } = {}) {
41
41
  additionalTimeout += serverIsReadyDelay;
42
42
  const testInfo = (0, getCurrentTest_1.getCurrentTest)();
43
43
  testInfo.runInfo = {
44
44
  cmd,
45
45
  cwd: cwd || getCwd(),
46
46
  additionalTimeout,
47
- testTimeout: TIMEOUT_JEST + additionalTimeout,
47
+ testFunctionTimeout: TIMEOUT_TEST_FUNCTION + additionalTimeout,
48
48
  serverIsReadyMessage,
49
49
  serverIsReadyDelay,
50
- debug,
50
+ inspect,
51
51
  };
52
- if (debug) {
52
+ if (inspect) {
53
53
  Logs_1.Logs.flushEagerly = true;
54
54
  }
55
55
  let runProcess = null;
@@ -118,7 +118,7 @@ function getRunInfo() {
118
118
  }
119
119
  async function start() {
120
120
  const { cmd, additionalTimeout, serverIsReadyMessage, serverIsReadyDelay } = getRunInfo();
121
- const done = (0, utils_1.logProgress)(` | [run] ${cmd}`);
121
+ const done = (0, utils_1.logProgress)(`| [run] ${cmd}`);
122
122
  let hasSuccessfullyStarted = false;
123
123
  let resolveServerStart;
124
124
  let rejectServerStart;
@@ -1,4 +1,4 @@
1
1
  export declare const cliConfig: {
2
2
  debugEsbuild: boolean;
3
- debug: boolean;
3
+ inspect: boolean;
4
4
  };
@@ -4,5 +4,5 @@ exports.cliConfig = void 0;
4
4
  const cliArgs = process.argv.slice(2);
5
5
  exports.cliConfig = {
6
6
  debugEsbuild: cliArgs.includes('--debug-esbuild'),
7
- debug: cliArgs.includes('--debug'),
7
+ inspect: cliArgs.includes('--inspect'),
8
8
  };
@@ -0,0 +1,4 @@
1
+ export { fsWindowsBugWorkaround };
2
+ export { fsWindowsBugWorkaroundPrefix };
3
+ declare const fsWindowsBugWorkaroundPrefix = "file://";
4
+ declare function fsWindowsBugWorkaround(testFileJs: string): string;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fsWindowsBugWorkaroundPrefix = exports.fsWindowsBugWorkaround = void 0;
4
+ const fsWindowsBugWorkaroundPrefix = 'file://';
5
+ exports.fsWindowsBugWorkaroundPrefix = fsWindowsBugWorkaroundPrefix;
6
+ // https://stackoverflow.com/questions/69665780/error-err-unsupported-esm-url-scheme-only-file-and-data-urls-are-supported-by/70057245#70057245
7
+ function fsWindowsBugWorkaround(testFileJs) {
8
+ return `${fsWindowsBugWorkaroundPrefix}${testFileJs}`;
9
+ }
10
+ exports.fsWindowsBugWorkaround = fsWindowsBugWorkaround;
@@ -6,3 +6,4 @@ export * from './isTTY';
6
6
  export * from './findFiles';
7
7
  export * from './logProgress';
8
8
  export * from './cliConfig';
9
+ export * from './fsWindowsBugWorkaround';
@@ -22,3 +22,4 @@ __exportStar(require("./isTTY"), exports);
22
22
  __exportStar(require("./findFiles"), exports);
23
23
  __exportStar(require("./logProgress"), exports);
24
24
  __exportStar(require("./cliConfig"), exports);
25
+ __exportStar(require("./fsWindowsBugWorkaround"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -27,6 +27,7 @@
27
27
  "@types/chai": "^4.3.3",
28
28
  "@types/node": "^15.6.1",
29
29
  "@types/node-fetch": "^2.5.12",
30
+ "@types/source-map-support": "^0.5.6",
30
31
  "typescript": "^4.8.3"
31
32
  },
32
33
  "repository": "github:brillout/test-e2e",