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

[heft-jest-plugin] update to jest 27 #3041

Closed

Conversation

rzyns
Copy link

@rzyns rzyns commented Nov 29, 2021

Summary

This updates the Jest dependency to the latest (~27.3.1) jest libraries.

Details

There are some breaking changes, which is to be expected when jumping two whole major versions. I'm not sure I've uncovered them all, the only one that seems to have affected the projects I've tested this on is disallowing done() callbacks in tests defined by asynchronous functions. I haven't measured performance quantitatively, but it feels like my builds are running faster with this change :)

How it was tested

  • ran rush update && rush rebuild in a fresh clone
  • proxied the package in my own Rush project of 27 packages (mix of browser and node), and ran rush update && rush rebuild many times to iteratively address the breaking changes in jest 27
  • ran rush rebuild several times after addressing the breaking changes, and it consistently builds cleanly now

Signed-off-by: Janusz Dziurzynski <rzyns@users.noreply.github.com>
…st-27

Conflicts:
      common/config/rush/browser-approved-packages.json
      common/config/rush/pnpm-lock.yaml
      common/config/rush/repo-state.json
Signed-off-by: Janusz Dziurzynski <rzyns@users.noreply.github.com>
@ghost
Copy link

ghost commented Nov 29, 2021

CLA assistant check
All CLA requirements met.

Signed-off-by: Janusz Dziurzynski <rzyns@users.noreply.github.com>
Jest 27 says:
> beforeEach() may not be used in a describe block containing no tests.

Signed-off-by: Janusz Dziurzynski <rzyns@users.noreply.github.com>
Signed-off-by: Janusz Dziurzynski <rzyns@users.noreply.github.com>
@ErikMikkelson
Copy link

Would it be worth updating jest-build-transform.ts to iterate over jestOptions.config.roots instead of hardcoding to package src? I have a modified version of the jest plugin for 27. which does that so we can keep our deployment code separate from our shipping code.

@rzyns
Copy link
Author

rzyns commented Nov 30, 2021

Would it be worth updating jest-build-transform.ts to iterate over jestOptions.config.roots instead of hardcoding to package src? I have a modified version of the jest plugin for 27. which does that so we can keep our deployment code separate from our shipping code.

Yeah, that's a good idea, @ErikMikkelson. Maybe that should be done in a separate PR, though? At this point, I just really, really want modern Jest support in main-line Rush, so I figured I'd try to change as little as possible in this PR. But if you have a specific example of what you want to see and you're inclined to share it, please do send it my way. In either case, I'll poke around a bit more in jest-build-transform.ts and see what I can do

@ErikMikkelson
Copy link

Yeah, that's a good idea, @ErikMikkelson. Maybe that should be done in a separate PR, though?

You're right, @rzyns , I don't want to derail your PR. I can set up a PR later.

If you're curious, the code was in jest-build-transform, you just wrap the process with something like

// CHANGECHANGE: Looping through all jestOptions.roots instead of assuming 'src' for (const root of (jestOptions.config.roots || [])) { const [subdir] = root.split('/').slice(-1); // Is the input file under the "src" folder? const srcFolder: string = path.join(jestOptions.config.rootDir, subdir);

The only other place to change is the jest config, of course.

rzyns added 2 commits December 6, 2021 11:37
…jest-27

Signed-off-by: Janusz Dziurzynski <rzyns@users.noreply.github.com>
…st-27

Signed-off-by: Janusz Dziurzynski <rzyns@users.noreply.github.com>
@D4N14L
Copy link
Member

D4N14L commented Dec 7, 2021

Hey @rzyns thanks for the PR! So I took some inspiration from this and created a separate PR with some additional changes. Feel free to take a look and try out this branch? #3076

@iclanton
Copy link
Member

Jest 27 has been released with @rushstack/heft-jest-plugin@0.2.0

@iclanton iclanton closed this Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants