|
| 1 | +import * as path from 'path'; |
| 2 | +import * as url from 'url'; |
1 | 3 | import type { TestResult } from '@jest/test-result'; |
2 | 4 | import type { |
3 | 5 | CallbackTestRunnerInterface, |
@@ -34,6 +36,15 @@ export default function createRunner< |
34 | 36 | runPath: string, |
35 | 37 | { getExtraOptions }: CreateRunnerOptions<ExtraOptions> = {}, |
36 | 38 | ) { |
| 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 | + |
37 | 48 | return class BaseTestRunner implements CallbackTestRunnerInterface { |
38 | 49 | #globalConfig: Config.GlobalConfig; |
39 | 50 |
|
@@ -123,7 +134,7 @@ export default function createRunner< |
123 | 134 | onFailure: OnTestFailure, |
124 | 135 | options: TestRunnerOptions, |
125 | 136 | ): Promise<void> { |
126 | | - const worker = new Worker(runPath, { |
| 137 | + const worker = new Worker(url.fileURLToPath(runPath), { |
127 | 138 | exposedMethods: ['default'], |
128 | 139 | numWorkers: this.#globalConfig.maxWorkers, |
129 | 140 | forkOptions: { stdio: 'inherit' }, |
|
0 commit comments