-
-
Notifications
You must be signed in to change notification settings - Fork 23
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 Jest and use TS for Jest config #97
Conversation
v27 is the latest version of Jest and introduces these major changes: * `node` is now the default environment instead of `jsdom`. This results in faster runtimes. * The runner has been completely rewritten as `jest-circus` which is also the default, replacing `jest-jasmine2`. * This should have no impact on us as we don't rely on any Jasmine-specific APIs, but is nice to know. * The "modern" version of Fake Timers (enabled via `jest.useFakeTimers("modern")`) is now the default. More info here: <https://jestjs.io/blog/2021/05/25/jest-27> Additionally, to ensure that we make use of all of the latest and greatest, this PR regenerates the Jest config file (as `jest.config.ts`). This has the added improvement that each option is now commented so we know exactly what each one does.
I started going through the new config, but it looks like most of our old config was discarded. Perhaps by mistake? Also lots of lint errors. |
// ], | ||
|
||
// An array of file extensions your modules use | ||
// moduleFileExtensions: [ |
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.
The default value matches our previously provided value, so I opted to leave the default.
// testLocationInResults: false, | ||
|
||
// The glob patterns Jest uses to detect test files | ||
// testMatch: [ |
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.
The default value covers more than the pattern we provided, but it also includes that pattern. Is there a reason why we want to override this? Was it just to communicate that test files ought to 1) be named *.test.ts
and 2) be colocated with implementation files?
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.
I'm guessing that it's because it used to diverge from the standard. The default seems fine to me.
@Gudahtt Apologies for the rush job on this, just wanted to make a PR based on the changes I'd made to |
files: ['jest.config.ts'], | ||
rules: { | ||
// TODO: Migrate to our shared config | ||
'import/no-anonymous-default-export': 'off', |
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.
👀
I was curious what this rule was for so I just looked up the original PR where it was added. Apparently the advantage is that it "improves the greppability of the codebase". That is, when searching for an identifier, sometimes it can be hard to find what you're looking for if that identifier is only in the filename and not represented in the file itself.
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.
I have definitely had that problem myself, so in general this rule seems beneficial to me. But it does seem out-of-place when applied to a top-level config file.
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.
LGTM!
v27 is the latest version of Jest and introduces these major changes:
node
is now the default environment instead ofjsdom
. Thisresults in faster runtimes.
jest-circus
which isalso the default, replacing
jest-jasmine2
.Jasmine-specific APIs, but is nice to know.
jest.useFakeTimers("modern")
) is now the default.More info here: https://jestjs.io/blog/2021/05/25/jest-27
Additionally, to ensure that we make use of all of the latest and
greatest, this PR regenerates the Jest config file (as
jest.config.ts
). This has the added improvement that each option isnow commented so we know exactly what each one does.