|
| 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,
|
@@ -36,6 +38,15 @@ export default function createRunner<
|
36 | 38 | runPath: string,
|
37 | 39 | { getExtraOptions }: CreateRunnerOptions<ExtraOptions> = {},
|
38 | 40 | ) {
|
| 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 | + |
39 | 50 | return class BaseTestRunner implements CallbackTestRunnerInterface {
|
40 | 51 | #globalConfig: Config.GlobalConfig;
|
41 | 52 |
|
@@ -121,7 +132,7 @@ export default function createRunner<
|
121 | 132 | onFailure: OnTestFailure,
|
122 | 133 | options: TestRunnerOptions,
|
123 | 134 | ): Promise<void> {
|
124 |
| - const worker = new Worker(runPath, { |
| 135 | + const worker = new Worker(url.fileURLToPath(runPath), { |
125 | 136 | exposedMethods: ['default'],
|
126 | 137 | numWorkers: this.#globalConfig.maxWorkers,
|
127 | 138 | forkOptions: { stdio: 'inherit' },
|
|
0 commit comments