-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Update Jest-related dependencies to latest version (v27) to address npm audit
problems
#9004
Conversation
@brainkim The remaining |
@@ -17,4 +17,5 @@ module.exports = { | |||
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'], | |||
testURL: 'http://localhost', | |||
setupFiles: ['<rootDir>/config/jest/setup.ts'], | |||
testEnvironment: 'jsdom', |
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.
Here's the change that reenables jsdom
for all tests. Should we restrict it to the ones that actually need it?
jest.runTimersToTime(230); | ||
jest.advanceTimersByTime(230); |
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.
Fortunately this was just a cosmetic change (renamed for clarity/accuracy): jestjs/jest#4723
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.
This is cool! Failed tests mode is still not working in Jest 27 for me, but I’m happy to see this merged.
Jest 27.0.0 was a significant major release with a number of breaking changes, so it's no surprise PRs like #8477 are failing. This PR is my manual attempt to address all of the hurdles involved in updating.
Closes #8324, #8841, #8910, #8325, #8477
The necessary changes fall into a few different categories:
jsdom
environment so tests running in Node.js have access to mockwindow
anddocument
objects (one-line change inconfig/jest.config.js
)done.fail
and the globalfail
function (many similar changes, mostly convertingdone
-style tests to use promises)jest.runTimersToTime
to the more accurately namedjest.advanceTimersToTime
It might go without saying, but a huge shout-out to TypeScript for making this kind of migration relatively straightforward, compared to the painstaking care that would be required if this was all pure JavaScript.
Perhaps more importantly, these updates collectively resolve a number of high-severity security vulnerabilities (not confirmed to have any impact on
@apollo/client
, but worth addressing).Before this PR (note how many of these problems are Jest-dependency-related):
With this PR:
I will continue investigating what's necessary to get this number down to zero.