Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support file URLs #193

Merged
merged 2 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions lib/createJestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type TestRunner = (runTestOptions: RunTestOptions) => TestResult;
export default function createRunner<
ExtraOptions extends Record<string, unknown>,
>(
runPath: string,
runPath: string | URL,
{ getExtraOptions }: CreateRunnerOptions<ExtraOptions> = {},
) {
return class BaseTestRunner implements CallbackTestRunnerInterface {
Expand Down Expand Up @@ -78,7 +78,7 @@ export default function createRunner<
onFailure: OnTestFailure,
options: TestRunnerOptions,
): Promise<void> {
const runner: TestRunner = (await import(runPath)).default;
const runner: TestRunner = (await import(runPath.toString())).default;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TS believes this must be a string, which is wrong. But it's also fine to just stringify it (since it's transpiled to require it's probably a good idea)


const mutex = pLimit(1);
return tests.reduce(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
30 changes: 15 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1659,17 +1659,17 @@ __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
"@types/istanbul-reports": ^3.0.0
"@types/node": "*"
"@types/yargs": ^17.0.8
chalk: ^4.0.0
checksum: 1756f4149d360f98567f56f434144f7af23ed49a2c42889261a314df6b6654c2de70af618fb2ee0ee39cadaf10835b885845557184509503646c9cb9dcc02bac
checksum: 1811f94b19cf8a9460a289c4f056796cfc373480e0492692a6125a553cd1a63824bd846d7bb78820b7b6f758f6dd3c2d4558293bb676d541b2fa59c70fdf9d39
languageName: node
linkType: hard

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down