-
Notifications
You must be signed in to change notification settings - Fork 721
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 #1892
base: master
Are you sure you want to change the base?
Upgrade jest #1892
Conversation
const { TextEncoder, TextDecoder } = require('util'); | ||
|
||
global.TextEncoder = TextEncoder; | ||
global.TextDecoder = TextDecoder; |
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've had to add this because jest-environment-jsdom
does not contain TextEncoder
and TextDecorder
, but react
requires them.
}, | ||
fakeTimers: { | ||
enableGlobally: true, | ||
legacyFakeTimers: true, |
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.
There is only a single test that fails when using the modern mock timers, but it wasn't immediately obvious how to fix this (probably just jest.useRealTimers()
?), so I've just kept using the legacy fake timers for now which were the default with jest 25.
expect(data[0].date.constructor).toEqual(Date); |
failed with
FAIL packages/visx-mock-data/test/genDateValue.test.ts
● generators/genDateValue › should return [{ date, value }]
expect(received).toEqual(expected) // deep equality
Expected: [Function ClockDate]
Received: [Function Date]
19 | const n = 1;
20 | const data = genDateValue(n);
> 21 | expect(data[0].date.constructor).toEqual(Date);
| ^
22 | expect(typeof data[0].value).toBe('number');
23 | });
24 |
at Object.toEqual (packages/visx-mock-data/test/genDateValue.test.ts:21:38)
There is another test referencing fake timers, so that one should be revisited as well when switching from legacy to modern fake timers:
visx/packages/visx-responsive/test/useScreenSize.test.ts
Lines 36 to 37 in 0614604
// fake timers in Jest 25 are completely unusable so I'm using real timers here | |
// when it's upgraded should be updated to use advanceTimersByTime |
e673fd7
to
0482ca3
Compare
The CI errors are probably caused by still using [email protected] (release over 3 years ago). We might need to upgrade typescript first. |
0482ca3
to
85957e0
Compare
thanks for starting this. I wanted to try the typescript 4 upgrade and thought it'd be worth pulling in these changes. have a wip branch here, lots of issues to work through #1894 |
🏠 Internal
jest
and related dependencies to the latest versionYet another step closer towards running tests with react@19 (#1883).