-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Build: Upgrade Jest to version 28 #19613
Conversation
I got most of the Angular test building now. The ones that I originally had building are now failing, but I think they will still be passing when that build issue is fixed. There are still Angular tests that need to be updated for v7 changes, but they seem to be building, at least. I also went through the other projects and fixed some of the issues I recognized for Jest 28 changes. As for configuration issues, Jest's |
# Conflicts: # code/addons/storyshots/storyshots-core/package.json # code/lib/api/package.json # code/yarn.lock
This allows us to run some projects with node, and others with browser environment
Even though there are no tests in here
Otherwise it's not possible to run a single file with the command line
OK, I have tests almost passing locally. There's one problem I can't figure out, in storyshots, that I need some help on. More on that later. The main change I made here is to break out the jest config into two separate files, To accomplish this, I needed to start using a multi-project based approach, rather than multi-root. Each project needs to have its own jest config, and these extend from either the browser config or the node config. This also has two nice side-benefits:
Here's what the project names look like: I'm not sure if I did a perfect job of breaking up node/browser packages, but the tests are passing so 🤷. We can also specify a different environment on a per-file basis, as I did in OK so here's what I still need help with. For some reason, a new snapshot is being created by the storyshots test, and it has the wrong path. It seems to be due to And, I had to re-ignore the angular tests, because they were failing (and taking forever to run). @Marklb maybe you can take a look, by removing the exclusion in the |
I guess CSF files get a I'm not 100% sure what the |
I am probably going to exclude https://github.com/storybookjs/storybook/blob/next/code/frameworks/angular/src/server/framework-preset-angular-cli.test.ts, because I think I can get the rest of Angular's tests working, but I am wondering if anyone has any ideas for how I can maybe solve the following issue blocking me on those tests. Here (https://github.com/storybookjs/storybook/blob/next/code/frameworks/angular/src/server/angular-cli-webpack-13.x.x.js#L27) we call I started looking for a way to alter that line, using a custom transformer, but the errors looked like the dynamically imported module didn't go through the transformers. I may be able to alter it another way, so that it does transform the code correctly. Even if I can get that code to work by altering that line with a transformer, is it worth going for that approach or would it be better to mock that function and just make sure the rest of our code is doing what is expected? |
757a775
to
71ae5ce
Compare
71ae5ce
to
6d7eee0
Compare
I'm so super confused by this. Everything passes locally, |
(and force correct jest-snapshot)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work!!
a42cd3b
to
c77276b
Compare
Phew, got the ✅ from CI finally. I have a few approvals from folks, and the longer this sits the more I need to rebase it, so I'm going to merge, and start working on the jest 29 upgrade as well as a few other cleanups. Thanks for the reviews, everyone, and thanks @Marklb for kicking this off. Let's try to get angular tests passing and turned on in a separate PR. |
Issue:
Angular tests have been excluded and they seem to be mostly fixed with Jest 28, so this is to try upgrading to Jest 28.
What I did
This updates the monorepo to use jest 28. Previously, we ran all tests in the
jsdom
environment, but the newer jest is more picky about it, and calls likesetImmediate
started to fail after the upgrade.So now we test some packages with a node environment and some with a jsdom environment. It does this by splitting the original jest config into two separate configs, one for browser environments, and one for node environments, and creating
jest.config.js
files in the root of each package. It's a little tedious, but it gives us greater control over how jest runs for each package, not only the environment, but other config as well.This also starts fixing Angular tests that have got behind while excluded, though we're not yet able to turn them back on just yet.
How to test
If your answer is yes to any of these, please make sure to include it in your PR.