Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set MODULE_NOT_FOUND code when module is not resolved from paths #8487

Merged
merged 13 commits into from
Nov 9, 2019
7 changes: 2 additions & 5 deletions packages/jest-resolve/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ class Resolver {
return null;
}

static createModuleNotFoundError(message?: string) {
return new ModuleNotFoundError(message);
}

resolveModuleFromDirIfExists(
dirname: Config.Path,
moduleName: string,
Expand Down Expand Up @@ -438,4 +434,5 @@ Please check your configuration for these entries:
return error;
};

export = Resolver;
export {ModuleNotFoundError};
export default Resolver;
thymikee marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions packages/jest-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {SourceMapRegistry} from '@jest/source-map';
import jestMock, {MockFunctionMetadata} from 'jest-mock';
import HasteMap, {ModuleMap} from 'jest-haste-map';
import {formatStackTrace, separateMessageFromStack} from 'jest-message-util';
import Resolver from 'jest-resolve';
import Resolver, {ModuleNotFoundError} from 'jest-resolve';
import {createDirectory, deepCyclicCopy} from 'jest-util';
import {escapePathForRegex} from 'jest-regex-util';
import Snapshot from 'jest-snapshot';
Expand Down Expand Up @@ -647,7 +647,7 @@ class Runtime {
return module;
}
}
const err = Resolver.createModuleNotFoundError(
const err = new ModuleNotFoundError(
`Cannot resolve module '${moduleName}' from paths ['${paths.join(
"', '",
)}'] from ${from}`,
Expand Down