continue-custom/jest.resolver.js
Tomasz Stefaniak fda6c3b508 fix: formatting
2025-08-08 13:05:40 -07:00

31 lines
905 B
JavaScript

module.exports = (path, options) => {
// Call the default resolver
const resolver = options.defaultResolver;
try {
// Try to resolve the path as-is first
return resolver(path, options);
} catch (error) {
// If the path ends with .js and resolution fails, try without the extension
if (path.endsWith(".js")) {
const pathWithoutJs = path.slice(0, -3);
try {
return resolver(pathWithoutJs, options);
} catch {
// If that also fails, try with .ts extension
try {
return resolver(pathWithoutJs + ".ts", options);
} catch {
// If that also fails, try with .tsx extension
try {
return resolver(pathWithoutJs + ".tsx", options);
} catch {
// If all attempts fail, throw the original error
throw error;
}
}
}
}
throw error;
}
};