Skip to content

Commit

Permalink
fix: alias nested testRunner paths
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph committed Aug 29, 2024
1 parent d4ffdca commit eb4f70e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion plugin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,25 @@ export default ({
: mapSingleReporter(reporter);
}

/** @param {string} testRunner */
function mapTestRunner(testRunner) {
if (testRunner) {
const segments = testRunner.split(sep);
const circusIndex = segments.indexOf('jest-circus');
const jasmine2Index = segments.indexOf('jest-jasmine2');

if (circusIndex > 0 && segments[circusIndex - 1] === 'node_modules') {
return 'jest-circus/runner';
}

if (jasmine2Index > 0 && segments[jasmine2Index - 1] === 'node_modules') {
return 'jest-jasmine2';
}
}

return testRunner;
}

async function moveExternalEntryPointsBackToRoot() {
for (const [input, output] of Object.entries(mapping)) {
const newPath = redirectExternalModule(output);
Expand Down Expand Up @@ -130,7 +149,7 @@ export default ({
setupFilesAfterEnv: projectConfig.setupFilesAfterEnv.map(mapFile),
testEnvironment: mapFile(projectConfig.testEnvironment),
testMatch: tests.map(mapFile),
testRunner: mapFile(projectConfig.testRunner),
testRunner: mapTestRunner(mapFile(projectConfig.testRunner)),
transform: undefined,
transformIgnorePatterns: undefined,
};
Expand Down

0 comments on commit eb4f70e

Please sign in to comment.