-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix(jest-config): throw correct error for missing preset modules #10737
Conversation
When loading a preset module that cannot be resolved (e.g. is not npm installed), the following error is shown to users: ● Validation Error: Preset foobar is invalid: The "id" argument must be of type string. Received null Instead, the following error should be shown ● Validation Error: Preset foobar not found. This PR changes the error message by handling when Resolver.findNodeModule returns null, indicating that the module cannot be successfully imported.
a374634
to
0c52b10
Compare
} catch {} | ||
|
||
// @ts-expect-error: `presetModule` can be null? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good stuff! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
When loading a preset module that cannot be resolved (e.g. is not npm
installed), the following error is shown to users:
Instead, the following error should be shown
This PR changes the error message by handling when
Resolver.findNodeModule returns null, indicating that the module cannot
be successfully imported.
Summary
The error currently presented when the preset module is missing is confusing, but also not the error intended to be shown.
For an example of confusion, see #10035
Test plan
To test yourself, add something like the following to your jest.config.js and observe the error message when running jest