Skip to content

Commit eb4f70e

Browse files
committed
fix: alias nested testRunner paths
1 parent d4ffdca commit eb4f70e

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

plugin.mjs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,25 @@ export default ({
8989
: mapSingleReporter(reporter);
9090
}
9191

92+
/** @param {string} testRunner */
93+
function mapTestRunner(testRunner) {
94+
if (testRunner) {
95+
const segments = testRunner.split(sep);
96+
const circusIndex = segments.indexOf('jest-circus');
97+
const jasmine2Index = segments.indexOf('jest-jasmine2');
98+
99+
if (circusIndex > 0 && segments[circusIndex - 1] === 'node_modules') {
100+
return 'jest-circus/runner';
101+
}
102+
103+
if (jasmine2Index > 0 && segments[jasmine2Index - 1] === 'node_modules') {
104+
return 'jest-jasmine2';
105+
}
106+
}
107+
108+
return testRunner;
109+
}
110+
92111
async function moveExternalEntryPointsBackToRoot() {
93112
for (const [input, output] of Object.entries(mapping)) {
94113
const newPath = redirectExternalModule(output);
@@ -130,7 +149,7 @@ export default ({
130149
setupFilesAfterEnv: projectConfig.setupFilesAfterEnv.map(mapFile),
131150
testEnvironment: mapFile(projectConfig.testEnvironment),
132151
testMatch: tests.map(mapFile),
133-
testRunner: mapFile(projectConfig.testRunner),
152+
testRunner: mapTestRunner(mapFile(projectConfig.testRunner)),
134153
transform: undefined,
135154
transformIgnorePatterns: undefined,
136155
};

0 commit comments

Comments
 (0)