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

Support for graceful extension of Jest config #6055

Merged
merged 1 commit into from
May 12, 2019

Conversation

jamesmfriedman
Copy link
Contributor

@jamesmfriedman jamesmfriedman commented Dec 17, 2018

This PR fixes what I believe to be a very necessary fix for Jest configuration. #6042

What it does

  • It adds 3 new keys to the allowedOverrides config
  • It gracefully extends any jest config option that is an object while leaving arrays and primitive types to override
  • Gracefully extending the objects made the most sense because it allows the original pieces to keep working as expected while give you the ability to fix things that would render the test framework useless for a project

We need to be able to update these keys for the following reasons

  • moduleNameMapper: I've worked on many many jobs and projects and have yet to find one that didn't take advantage of aliasing in someway. If a project is using aliasing (despite CRAs efforts to continue to block it?) it renders the test framework useless.
  • transform: adding any additional file types or loaders to a project will render this broken. Specifically here, I know people need to use jest-transform-graphql
  • transformIgnorePatterns: This is really the reason this PR was created in the first place, the above two items were just logical additions... If someone distributes ES6 / ESNext code and you are using it in your project, you can no longer use Jest. While we can promote in a perfect world that everyone ships ES5 code, first class browser support for ES6 is making this less true. Also, some codebases intentionally use ES6 code since it results in smaller end user bundles. Lastly, The dev / build system supports this while Jest does not!

My current Jest key in package.json
image

Config before change, lacking my additions
image

Config after this PR :)
image

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@stale
Copy link

stale bot commented Jan 18, 2019

This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Jan 18, 2019
@jamesmfriedman
Copy link
Contributor Author

I had an open issue with that seemed to indicate this would be an ok addition. Something preventing it from being approved?

#6042

@stale stale bot removed the stale label Jan 18, 2019
@jamesmfriedman
Copy link
Contributor Author

Any word on this?

1 similar comment
@jamesmfriedman
Copy link
Contributor Author

Any word on this?

@stale
Copy link

stale bot commented Mar 22, 2019

This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale
Copy link

stale bot commented Mar 29, 2019

This pull request has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue. Thank you for your contribution!

@stale stale bot closed this Mar 29, 2019
@jamesmfriedman
Copy link
Contributor Author

What the heck? This was a fix for an issue where a contributor said to do it.

@iansu iansu removed the stale label Mar 31, 2019
@iansu iansu reopened this Mar 31, 2019
@jamesmfriedman
Copy link
Contributor Author

Thanks!

Copy link
Contributor

@petetnt petetnt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jamesmfriedman,

first of all, sorry for the late response.

I'd revert the other changes than those in createJestConfig.js ( merge issues? or is GH UI just fooling me). Also these additional keys need to be documented in https://facebook.github.io/create-react-app/docs/running-tests#configuration

Otherwise I am a-okay with the idea itself

Thanks!

@ianschmitz ianschmitz closed this Apr 2, 2019
@ianschmitz ianschmitz reopened this Apr 2, 2019
@jamesmfriedman
Copy link
Contributor Author

Yeah weird, those all popped in after I rebased 🙄. I’ll just port the changes over to the latest master and force push over this branch.

@stale
Copy link

stale bot commented May 2, 2019

This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label May 2, 2019
@jamesmfriedman
Copy link
Contributor Author

@petetnt took me a while to remembe to get back to this, fixed my PR as requested ^

@jamesmfriedman
Copy link
Contributor Author

Commenting so it doesn't got stale again

@mrmckeb
Copy link
Contributor

mrmckeb commented May 12, 2019

This is great, thanks @jamesmfriedman.

Would you mind adding a PR to document this?

@mrmckeb mrmckeb merged commit e2f43a0 into facebook:master May 12, 2019
@jamesmfriedman
Copy link
Contributor Author

Glad this finally made it in! Yeah sure thing. Haven’t looked since the new docs site went live but I’m assuming the src is in the repo? I’ll assume yes unless you tell me otherwise.

@mrmckeb
Copy link
Contributor

mrmckeb commented May 13, 2019

That's correct @jamesmfriedman

@lock lock bot locked and limited conversation to collaborators May 18, 2019
@ianschmitz ianschmitz added this to the 3.0.2 milestone Jun 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants