Skip to content

Commit

Permalink
fix(test): fix custom jest resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaAga authored and Ron-Lavi committed May 31, 2022
1 parent b3a6030 commit 83020eb
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/test/src/resolveNodeModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ const resolveNodeModule = (sourcePath, currentFile) => {
currentFileDirectory,
});

const results = process.version.startsWith('v10')
? currentFile.defaultResolver(moduleToResolve, currentFile)
: require.resolve(moduleToResolve, {
paths: [currentFileDirectory],
});
let results;
try {
results = require.resolve(moduleToResolve, {
paths: [currentFileDirectory],
});
} catch (error) {
results = currentFile.defaultResolver(moduleToResolve, currentFile);
}

return rootDir
? results.replace(
Expand Down

0 comments on commit 83020eb

Please sign in to comment.