From 83020eb093703037953e037910320bea9157332c Mon Sep 17 00:00:00 2001 From: MariaAga Date: Tue, 31 May 2022 17:42:26 +0200 Subject: [PATCH] fix(test): fix custom jest resolver --- packages/test/src/resolveNodeModule.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/test/src/resolveNodeModule.js b/packages/test/src/resolveNodeModule.js index 2958ff95..cc5f6983 100644 --- a/packages/test/src/resolveNodeModule.js +++ b/packages/test/src/resolveNodeModule.js @@ -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(