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
Bump Jest to v27 #1198
Bump Jest to v27 #1198
Conversation
New dependency changes detected. Learn more about Socket for GitHub ↗︎ 👍 No new dependency issues detected in pull request Bot CommandsTo ignore an alert, reply with a comment starting with Pull request alert summary
📊 Modified Dependency Overview:
|
The test errors seem to be due to breaking changes in v28 that requires us to do changes in the setup. https://jestjs.io/docs/28.x/upgrading-to-jest28#jsdom I'd suggest to
|
@legobeat Ah, thanks! I've updated this PR to bump Jest to only v27. |
@@ -44,7 +44,7 @@ function flushPromises(): Promise<unknown> { | |||
|
|||
describe('CurrencyRateController', () => { | |||
beforeEach(() => { | |||
jest.useFakeTimers(); |
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.
Changed because Jest v27 switches to the "modern" fake timers by default and these must mock more things related to timers than the legacy fake timers, because now any of the tests that involve HTTP requests are timing out. I suspect because this is because node-fetch
calls setTimeout
on the request object during the request-response flow, but I didn't look beyond that.
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.
More information on this: nock/nock#2200
It seems that using the legacy implementation is the best solution for now. Jest v28 offers more options though. When we update to v28 we should consider using the modern timers but configuring it to leave whatever we need here unmocked.
@@ -16,7 +16,7 @@ module.exports = merge(baseConfig, { | |||
// An object that configures minimum threshold enforcement for coverage results | |||
coverageThreshold: { | |||
global: { | |||
branches: 81.51, | |||
branches: 80.79, |
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.
Do we have an explanation for this?
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.
Hmm, that's fair. Let me dive deeper into the coverage reports.
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.
Rebased on main
(there were some yarn.lock conflicts) and ran a project-wide jest-it-up
- the drop here persists.
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.
For the preferences controller tests, the branch coverage went from 22/24 to 13/15. Here in the transactions controller, branch coverage went from 217/264 to 185/229
The reports seem to show the same gaps, roughly. I did a visual comparison and they were nearly identical. The one difference is that the else case for this condition used to be flagged as uncovered, but now it isn't.
I did a quick search in the Jest issue tracker but couldn't find any reference to this.
This is curious, but I don't think it needs to block this PR.
The `mocked` utility function from `ts-jest`, which we commonly use, was moved into Jest in v27.
c186550
to
0503bbb
Compare
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.
Looks great! I can approve once the conflicts are resolved
@@ -16,7 +16,7 @@ module.exports = merge(baseConfig, { | |||
// An object that configures minimum threshold enforcement for coverage results | |||
coverageThreshold: { | |||
global: { | |||
branches: 86.67, |
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.
Had to do this after merge of main
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!
* Bump Jest to v27 The `mocked` utility function from `ts-jest`, which we commonly use, was moved into Jest in v27. * jest-it-down --------- Co-authored-by: legobt <6wbvkn0j@anonaddy.me> Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
* Bump Jest to v27 The `mocked` utility function from `ts-jest`, which we commonly use, was moved into Jest in v27. * jest-it-down --------- Co-authored-by: legobt <6wbvkn0j@anonaddy.me> Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
Description
The
mocked
utility function fromts-jest
, which we commonly use, was moved into Jest in v27.Changes
N/A
References
This is a blocker for #1197, as we want to update the NetworkController tests to use
jest.mocked
instead ofmocked
fromts-jest/utils
.Checklist