Skip to content

Commit

Permalink
convert to URL for import
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Sep 14, 2022
1 parent 900d54e commit 324b85f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/createJestRunner.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as path from 'path';
import * as url from 'url';
import type { TestResult } from '@jest/test-result';
import type {
CallbackTestRunnerInterface,
Expand Down Expand Up @@ -36,6 +38,15 @@ export default function createRunner<
runPath: string,
{ getExtraOptions }: CreateRunnerOptions<ExtraOptions> = {},
) {
if (!runPath.startsWith('file')) {
if (!path.isAbsolute(runPath)) {
throw new Error(`Path must be absolute - got ${runPath}`);
}

// eslint-disable-next-line no-param-reassign
runPath = url.pathToFileURL(runPath).href;
}

return class BaseTestRunner implements CallbackTestRunnerInterface {
#globalConfig: Config.GlobalConfig;

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

0 comments on commit 324b85f

Please sign in to comment.