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

Upgrade to Jest 25 #8362

Merged
merged 8 commits into from
May 4, 2020
Merged

Upgrade to Jest 25 #8362

merged 8 commits into from
May 4, 2020

Conversation

skovhus
Copy link
Contributor

@skovhus skovhus commented Jan 22, 2020

Fixes #8361, fixes #8689, fixes #7491.

QA

I hope that CI will ensure that Jest 25 works.

But I'm wondering what is the best way to try link react-script into an existing application and try it out? I'll try to verify that the suggested changes will work with the CRA-powered apps that I'm currently working on.

@ianschmitz
Copy link
Contributor

We may need to be careful with this one due to the updated version of jsdom used. It could break tests for people. Some more thought is probably needed.

@mAAdhaTTah
Copy link

Yeah, if CRA still supports Node 8, this won't work. I believe that was the major blocker preventing Jest from upgrading. The new version drops Node 8 support.

@ianschmitz
Copy link
Contributor

Jest 25 supports node 8.

@mAAdhaTTah
Copy link

Whoops, you're right, I was thinking of Node 6. Nevermind!

@skovhus
Copy link
Contributor Author

skovhus commented Jan 26, 2020

We may need to be careful with this one due to the updated version of jsdom used. It could break tests for people. Some more thought is probably needed.

Can/should we make the jsdom version configurable?

@ianschmitz
Copy link
Contributor

Can/should we make the jsdom version configurable?

You can use --env to configure the environment, including using a different version of jsdom via one of the support packages (https://www.npmjs.com/package/jest-environment-jsdom-fifteen, etc)

@skovhus
Copy link
Contributor Author

skovhus commented Feb 1, 2020

We may need to be careful with this one due to the updated version of jsdom used. It could break tests for people. Some more thought is probably needed.

let me know what I can do to help.

@ianschmitz
Copy link
Contributor

Hmm.. Now that i think about it we may be able to upgrade to Jest 25, but force it onto the older version of jsdom by default, while still offering the option for folks to opt-in to the newest jsdom via the support package and the --env flag.

Let me put some thought into this. I'll check it out to see if there's any compat issues with newer jest + old jsdom.

@skovhus
Copy link
Contributor Author

skovhus commented Feb 10, 2020

Let us know if you have some insights here on the compatibility @SimenB?

@SimenB
Copy link
Contributor

SimenB commented Feb 10, 2020

👋
Don't you already default to a custom jsdom version in CRA? That should work the same in 24 as 25.

But yeah, in theory the only user facing breaking changes in jest 25 is node 8 and jsdom 15, which was the goal to make upgrade as simple as possible

@stale
Copy link

stale bot commented Mar 11, 2020

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.

@eps1lon
Copy link
Contributor

eps1lon commented Mar 13, 2020

The latest @testing-library/react requires jsdom@13. Would be nice to land this so that users don't have to manually add the proper jsdom environment.

@stale stale bot removed the stale label Mar 13, 2020
@transmissions11
Copy link

Testing-Library dearly needs this upgrade! Hope we can get this merged ASAP. 😄

@mrmckeb
Copy link
Contributor

mrmckeb commented Mar 15, 2020

I agree with @ianschmitz, this could be a breaking change for some users, so we need to tread carefully.

I think a flag could be the way for now, enabling us to do a minor release.

@eps1lon
Copy link
Contributor

eps1lon commented Mar 15, 2020

I agree with @ianschmitz, this could be a breaking change for some users, so we need to tread carefully.

To be clear: In almost all cases this will be breaking because your test was either unknowingly invalid i.e. did things that wouldn't be possible in a browser or explicitly included jsdom workarounds. In either case this bugfix should be preferred over the "ignoreance is bliss"-test.

@ambroseus
Copy link

ambroseus commented Mar 22, 2020

+1 reason to update jest to 25.1: #8689 (comment)
Solves #8689

@ianschmitz ianschmitz added this to the 3.4.2 milestone Apr 6, 2020
peterMuriuki added a commit to onaio/reveal-frontend that referenced this pull request Apr 14, 2020
running tests with coverage flag produces the below errors:

Handlebars: Access has been denied to resolve the property "statements" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "branches" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "functions" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "lines" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details

This happens to have been yet another breaking change that does not
respect semver versioning for `handlebars` package. This is a package whose
dependecy graph is as follows: react-scripts/jest/jest-cli/istanbul-reporters/handlebars.

We cannot simply remove and add the correct minor version for handlebars to fix this error
, One other alternative would be upgrading the react-scripts version to a version
where they have upgraded all the underlying dependencies all the way to
istanbul-reporters; to a version of the latter that recognizes and is able to work
with the handlebars' changed api. This version of react-scripts does not yet exist
but there is a Pr for it here facebook/create-react-app#8362.

The other alternative and option was to use selective dependency resolution
to override and specify a jest version without needlessy upgrading react-scripts.

This has the disadvantage that we get a few warnings of some configuration options
that jest has deprecated that the current version of react-scripts uses.
@ianschmitz ianschmitz modified the milestones: 3.5, 4.0 May 3, 2020
@ianschmitz ianschmitz merged commit 9904075 into facebook:master May 4, 2020
@kentcdodds
Copy link
Contributor

FYI, jest@26 alpha had been released

@SimenB
Copy link
Contributor

SimenB commented May 4, 2020

That's way more breaking than 25, so definitely needs to go in a major release.

(Scheduled for release tonight or tomorrow, just need to wrap up the the blog post and that has to wait for my day job 😃)

@ianschmitz
Copy link
Contributor

@SimenB i had seen your 26 milestone and wanted to chat with you about timing - couldn't DM you on Twitter 😢. Thanks for the heads up. We'll roll Jest 26 into our 4.0 release which we're planning this week.

@ianschmitz ianschmitz mentioned this pull request May 4, 2020
@SimenB
Copy link
Contributor

SimenB commented May 4, 2020

https://github.com/facebook/jest/releases/tag/v26.0.0

It's out 😀 We wanted to release now so people can play with it and ship the blog post tomorrow in case we need some quick patch releases


@ianschmitz ah sorry, seems I turned that off at some point

@kentcdodds
Copy link
Contributor

Having Jest 26 in 4.0 will be AMAZING 😍

Can't wait to get the latest of Jest and JSDOM by default. This brings my heart much joy!! 🎊

Huge thank you to both of you for the amazing work you tirelessly do each day.

/giphy thank you

@skovhus
Copy link
Contributor Author

skovhus commented May 4, 2020

This is great news! Thanks for merging this. 👏

@skovhus skovhus deleted the jest-25 branch May 4, 2020 19:45
@timini
Copy link

timini commented May 8, 2020

is there any plan to have a CRA release with jest 25 ? i NEED this

@kentcdodds
Copy link
Contributor

kentcdodds commented May 8, 2020

I believe CRA will be released with jest 26 soon.

@lock lock bot locked and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet