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

Scripts: Upgrade Jest to the new major version (26.x) #22395

Closed
4 tasks
gziolo opened this issue May 15, 2020 · 0 comments · Fixed by #27956
Closed
4 tasks

Scripts: Upgrade Jest to the new major version (26.x) #22395

gziolo opened this issue May 15, 2020 · 0 comments · Fixed by #27956
Assignees
Labels
[Package] Jest preset /packages/jest-preset-default [Package] Scripts /packages/scripts [Status] In Progress Tracking issues with work in progress [Type] Breaking Change For PRs that introduce a change that will break existing functionality
Projects

Comments

@gziolo
Copy link
Member

gziolo commented May 15, 2020

Jest v26.0.0 was released:

https://jestjs.io/blog/2020/05/05/jest-26

We should update our packages to use the latest version. It has a few breaking changes as noted in the announcement post. One of them was already addressed in #22370 by @aduth:

  • [jest-runtime] Remove long-deprecated require.requireActual and require.requireMock methods

We might need more tweaks but only by looking at changelog, I couldn't identify anything obvious that would create issues. We will find out during the process :)

Bonus tasks

There are also some new features or breaking changes scheduled for the next major releases that could be addressed as a follow-ups:

  • New fake timers – https://jestjs.io/blog/2020/05/05/jest-26#new-fake-timers:

    In Jest 26, this new implementation will remain opt-in and can be activated by calling jest.useFakeTimers('modern') or by passing modern to the timers option in your config if you opted all tests into fake timers previously.

    It feels like the option based on the config file would be easier (assuming it works out of the box).

  • New way to consume Jest - @jest/globalshttps://jestjs.io/blog/2020/05/05/jest-26#a-new-way-to-consume-jest---jestglobals

    We added a new package @jest/globals that can be used to import testing functions: import {expect, jest, test} from '@jest/globals';.

  • New test runner "jest-circus" and Node.js env enabled by default – we will need to decide if we follow or keep JSDOM as a default one (*):

    Jest 27 will ship with a new test runner "jest-circus" and the Node.js environment by default. jest-jasmine2 and jest-environment-jsdom will still be bundled so users can keep using them by changing one-line each in the configuration.

  • jest-environment-jsdom needs to become an explicit dependency:

    Jest 28 will remove jest-jasmine2 and jest-environment-jsdom from the default distribution of Jest. The packages will still be actively maintained as part of the Jest project and be published separately. Users will need to install these packages to use them.

(*) - there is this issue filed #17273 which would be resolved if we would set the default testing env to Node.js: "Add integration test which ensures that npm packages can be used with Node" :)

References

It might be helpful to look at previous PR where major version upgrade for Jest was applied: #20766. The changes included:

  • upgrade of Jest package to the latest version
  • bringing all Jest related packages used to the latest version
  • listing all changes applied in the relevant changelog files
  • fixing any failing tests that might pop up

Note: when migrating from Jest 24 to 25, we rewrote several failing tests covering React components to use React Testing Library rather than Enzyme.

@gziolo gziolo added Needs Dev Ready for, and needs developer efforts [Type] Breaking Change For PRs that introduce a change that will break existing functionality [Package] Scripts /packages/scripts [Package] Jest preset /packages/jest-preset-default labels May 15, 2020
@gziolo gziolo added this to To do in Core JS May 15, 2020
@gziolo gziolo added this to the @wordpress/scripts v13 milestone Dec 19, 2020
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jan 1, 2021
@gziolo gziolo moved this from To do to In progress in Core JS Jan 1, 2021
@gziolo gziolo removed the Needs Dev Ready for, and needs developer efforts label Jan 1, 2021
@gziolo gziolo removed this from the @wordpress/scripts v13 milestone Jan 2, 2021
@gziolo gziolo moved this from In progress to Done in Core JS Jan 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Jest preset /packages/jest-preset-default [Package] Scripts /packages/scripts [Status] In Progress Tracking issues with work in progress [Type] Breaking Change For PRs that introduce a change that will break existing functionality
Projects
No open projects
Core JS
  
Done
Development

Successfully merging a pull request may close this issue.

1 participant