-
Notifications
You must be signed in to change notification settings - Fork 250
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(jest): support more config file formats #3761
Conversation
Support more config file formats in jest.
There is a complication with this approach. It might result in this error:
For both running regular unit tests as running stryker-js. This happens when a user installed This happens because
(or The way to solve this is actually not that big of a deal: install
I still like the solution proposed in this PR. An alternative might be to use the preinstalled version of
@jimCresswell @bmordue @chaouiyounes11 what would you guys prefer? @SimenB feel free to pitch in as well 😅 |
Thanks @nicojs !
I prefer this solution as well, it is more transparent to the end user, and also gives them the opportunity to solve the problem by updating their dependencies. I think the only caveat is that it needs to be well documented in a way that is easy to find with a quick search. |
I'd try to load const {createRequire} = require('module');
const requireFromJest = createRequire(require.resolve('jest'));
const requireFromJestCli = createRequire(requireFromJest.resolve('jest-cli'));
const jestConfigFromJest = requireFromJestCli('jest-config');
// or requireFromJestCli('jest-config/package.json'); if you wanna look at e.g. the exact version We've talked about splitting out defaults from |
Thanks, @SimonB, and @jimCresswell for the advice. I'm tempted to go with @SimonB's approach, simply because it would save a lot of headaches for existing users. One big downside is that |
RN and Metro recently upgraded to Jest 29, so CRA might be able to as well 🙂 (assuming the holdup is Meta and not CRA itself). EDIT: Seems like it's CRA 😛 facebook/create-react-app#12662 |
Either way, I am very excited about being able to validate the unit tests in Next.js projects. |
I've implemented @SimenB 's suggestion. I also added custom support for exporting an |
💥 |
Thanks for all help and feedback everyone! ♥ |
Support all config file formats for jest using jest's native config reading (including
jest.config.ts
). See https://jestjs.io/docs/configuration for a list of all available config formats.Stryker only uses jest's native functionality if it finds
jest@>=29.2
, otherwise, it falls back on its custom config file reading algorithm.This also adds support for exporting an
async
function from your jest config file even forjest@<29.2
, because of added functionality in the custom config loading logic.See jestjs/jest#13356
Fixes #3710
Fixes #3480
Fixes #3476