Skip to content

Commit

Permalink
fix: correctly throw an error if jest-environment-jsdom is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Apr 26, 2022
1 parent b30f908 commit db47639
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/jest-resolve/src/utils.ts
Expand Up @@ -98,6 +98,11 @@ export const resolveTestEnvironment = ({
testEnvironment: string;
requireResolveFunction: (moduleName: string) => string;
}): string => {
// we don't want to resolve the actual `jsdom` env if `jest-environment-jsdom` is not installed
if (filePath === 'jsdom') {
filePath = 'jest-environment-jsdom';
}

try {
return resolveWithPrefix(undefined, {
filePath,
Expand All @@ -108,7 +113,7 @@ export const resolveTestEnvironment = ({
rootDir,
});
} catch (error: any) {
if (filePath === 'jsdom' || filePath === 'jest-environment-jsdom') {
if (filePath === 'jest-environment-jsdom') {
error.message +=
'\n\nAs of Jest 28 "jest-environment-jsdom" is no longer shipped by default, make sure to install it separately.';
}
Expand Down

0 comments on commit db47639

Please sign in to comment.