Skip to content

Commit 8dc3bf3

Browse files
committed
convert to URL for import
1 parent bdbe550 commit 8dc3bf3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/createJestRunner.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as path from 'path';
2+
import * as url from 'url';
13
import type { TestResult } from '@jest/test-result';
24
import type {
35
CallbackTestRunnerInterface,
@@ -34,6 +36,15 @@ export default function createRunner<
3436
runPath: string,
3537
{ getExtraOptions }: CreateRunnerOptions<ExtraOptions> = {},
3638
) {
39+
if (!runPath.startsWith('file')) {
40+
if (!path.isAbsolute(runPath)) {
41+
throw new Error(`Path must be absolute - got ${runPath}`);
42+
}
43+
44+
// eslint-disable-next-line no-param-reassign
45+
runPath = url.pathToFileURL(runPath).href;
46+
}
47+
3748
return class BaseTestRunner implements CallbackTestRunnerInterface {
3849
#globalConfig: Config.GlobalConfig;
3950

@@ -123,7 +134,7 @@ export default function createRunner<
123134
onFailure: OnTestFailure,
124135
options: TestRunnerOptions,
125136
): Promise<void> {
126-
const worker = new Worker(runPath, {
137+
const worker = new Worker(url.fileURLToPath(runPath), {
127138
exposedMethods: ['default'],
128139
numWorkers: this.#globalConfig.maxWorkers,
129140
forkOptions: { stdio: 'inherit' },

0 commit comments

Comments
 (0)