Skip to content

Commit 324b85f

Browse files
committed
convert to URL for import
1 parent 900d54e commit 324b85f

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,
@@ -36,6 +38,15 @@ export default function createRunner<
3638
runPath: string,
3739
{ getExtraOptions }: CreateRunnerOptions<ExtraOptions> = {},
3840
) {
41+
if (!runPath.startsWith('file')) {
42+
if (!path.isAbsolute(runPath)) {
43+
throw new Error(`Path must be absolute - got ${runPath}`);
44+
}
45+
46+
// eslint-disable-next-line no-param-reassign
47+
runPath = url.pathToFileURL(runPath).href;
48+
}
49+
3950
return class BaseTestRunner implements CallbackTestRunnerInterface {
4051
#globalConfig: Config.GlobalConfig;
4152

@@ -121,7 +132,7 @@ export default function createRunner<
121132
onFailure: OnTestFailure,
122133
options: TestRunnerOptions,
123134
): Promise<void> {
124-
const worker = new Worker(runPath, {
135+
const worker = new Worker(url.fileURLToPath(runPath), {
125136
exposedMethods: ['default'],
126137
numWorkers: this.#globalConfig.maxWorkers,
127138
forkOptions: { stdio: 'inherit' },

0 commit comments

Comments
 (0)