From 86ef37153356228da1159ce87742daefe8e9b04d Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Mon, 6 Mar 2023 14:43:33 +0100 Subject: [PATCH] feat: support file URLs (#193) --- README.md | 2 +- lib/createJestRunner.ts | 4 ++-- package.json | 2 +- yarn.lock | 30 +++++++++++++++--------------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 9cb581c..c08cb89 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ module.exports = createJestRunner(require.resolve('./run')); #### createJestRunner(pathToRunFile, config?: { getExtraOptions }) -- `pathToRunFile`: path to your run file. +- `pathToRunFile`: path to your run file. This must be an absolute path or a `file://` URL. - `config`: Optional argument for configuring the runner. - `getExtraOptions`: `() => object` used for passing extra options to the runner. It needs to be a serializable object because it will be send to a different Node process. diff --git a/lib/createJestRunner.ts b/lib/createJestRunner.ts index 301e8db..38324fe 100644 --- a/lib/createJestRunner.ts +++ b/lib/createJestRunner.ts @@ -33,7 +33,7 @@ type TestRunner = (runTestOptions: RunTestOptions) => TestResult; export default function createRunner< ExtraOptions extends Record, >( - runPath: string, + runPath: string | URL, { getExtraOptions }: CreateRunnerOptions = {}, ) { return class BaseTestRunner implements CallbackTestRunnerInterface { @@ -78,7 +78,7 @@ export default function createRunner< onFailure: OnTestFailure, options: TestRunnerOptions, ): Promise { - const runner: TestRunner = (await import(runPath)).default; + const runner: TestRunner = (await import(runPath.toString())).default; const mutex = pLimit(1); return tests.reduce( diff --git a/package.json b/package.json index 7b5d96e..91849ea 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ }, "dependencies": { "chalk": "^4.1.0", - "jest-worker": "^29.0.0", + "jest-worker": "^29.5.0", "p-limit": "^3.1.0" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index 015bbe9..40b5d1e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1659,9 +1659,9 @@ __metadata: languageName: node linkType: hard -"@jest/types@npm:^29.4.3": - version: 29.4.3 - resolution: "@jest/types@npm:29.4.3" +"@jest/types@npm:^29.4.3, @jest/types@npm:^29.5.0": + version: 29.5.0 + resolution: "@jest/types@npm:29.5.0" dependencies: "@jest/schemas": ^29.4.3 "@types/istanbul-lib-coverage": ^2.0.0 @@ -1669,7 +1669,7 @@ __metadata: "@types/node": "*" "@types/yargs": ^17.0.8 chalk: ^4.0.0 - checksum: 1756f4149d360f98567f56f434144f7af23ed49a2c42889261a314df6b6654c2de70af618fb2ee0ee39cadaf10835b885845557184509503646c9cb9dcc02bac + checksum: 1811f94b19cf8a9460a289c4f056796cfc373480e0492692a6125a553cd1a63824bd846d7bb78820b7b6f758f6dd3c2d4558293bb676d541b2fa59c70fdf9d39 languageName: node linkType: hard @@ -2738,7 +2738,7 @@ __metadata: execa: ^5.0.0 jest: ^29.0.0 jest-runner: ^29.0.0 - jest-worker: ^29.0.0 + jest-worker: ^29.5.0 p-limit: ^3.1.0 prettier: ^2.0.5 strip-ansi: ^6.0.0 @@ -4532,17 +4532,17 @@ __metadata: languageName: node linkType: hard -"jest-util@npm:^29.4.3": - version: 29.4.3 - resolution: "jest-util@npm:29.4.3" +"jest-util@npm:^29.4.3, jest-util@npm:^29.5.0": + version: 29.5.0 + resolution: "jest-util@npm:29.5.0" dependencies: - "@jest/types": ^29.4.3 + "@jest/types": ^29.5.0 "@types/node": "*" chalk: ^4.0.0 ci-info: ^3.2.0 graceful-fs: ^4.2.9 picomatch: ^2.2.3 - checksum: 606b3e6077895baf8fb4ad4d08c134f37a6b81d5ba77ae654c942b1ae4b7294ab3b5a0eb93db34f129407b367970cf3b76bf5c80897b30f215f2bc8bf20a5f3f + checksum: fd9212950d34d2ecad8c990dda0d8ea59a8a554b0c188b53ea5d6c4a0829a64f2e1d49e6e85e812014933d17426d7136da4785f9cf76fff1799de51b88bc85d3 languageName: node linkType: hard @@ -4576,15 +4576,15 @@ __metadata: languageName: node linkType: hard -"jest-worker@npm:^29.0.0, jest-worker@npm:^29.4.3": - version: 29.4.3 - resolution: "jest-worker@npm:29.4.3" +"jest-worker@npm:^29.4.3, jest-worker@npm:^29.5.0": + version: 29.5.0 + resolution: "jest-worker@npm:29.5.0" dependencies: "@types/node": "*" - jest-util: ^29.4.3 + jest-util: ^29.5.0 merge-stream: ^2.0.0 supports-color: ^8.0.0 - checksum: c99ae66f257564613e72c5797c3a68f21a22e1c1fb5f30d14695ff5b508a0d2405f22748f13a3df8d1015b5e16abb130170f81f047ff68f58b6b1d2ff6ebc51b + checksum: 1151a1ae3602b1ea7c42a8f1efe2b5a7bf927039deaa0827bf978880169899b705744e288f80a63603fb3fc2985e0071234986af7dc2c21c7a64333d8777c7c9 languageName: node linkType: hard