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 from 26 to 29 #4686
Conversation
"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.
Retain legacy timer expectations.
"snapshotFormat": { | ||
"escapeString": true, | ||
"printBasicPrototype": 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.
Retain legacy snapshot format.
const {disallowWarnings, expectWarningWillFire} = (jest.requireActual( | ||
'relay-test-utils-internal', | ||
): $FlowFixMe); |
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.
Avoid module getting reset when jest.resetModules
is called somewhere in this test, otherwise expectWarningWillFire
errors.
@@ -2491,7 +2490,6 @@ describe('useBlockingPaginationFragment', () => { | |||
// the component twice: `expectFragmentResults` will fail in the next | |||
// test | |||
jest.resetModules(); | |||
disallowWarnings(); |
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.
Cannot nest this function within a test, because it contains an internal call to afterEach
. I'm assuming this was done because of the resetModules
, but preventing the module from being reset avoids the issue without triggering the new error about nesting jest hooks
disallowWarnings(); | ||
disallowConsoleErrors(); |
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.
Cannot nest afterEach
within beforeEach
setTimeout(() => { | ||
resolve(markdownRendererNormalizationFragment); | ||
}); | ||
}, 0); |
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.
Only use of setImmediate
in the tests. No test failures from this change - possibly there are console messages related to it but they were truncated in the test output.
@@ -10,6 +10,7 @@ | |||
|
|||
'use strict'; | |||
|
|||
global.IS_REACT_ACT_ENVIRONMENT = 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.
Needed after upgrading jest
@@ -38,7 +38,7 @@ module.exports = { | |||
filename: filename, | |||
retainLines: true, | |||
}); | |||
return babel.transform(src, options).code; | |||
return babel.transform(src, options); |
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 API changed between 26 and 29
const { | ||
FIXTURE_TAG, | ||
generateTestsFromFixtures, | ||
} = require('./generateTestsFromFixtures'); |
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 module uses Node.js APIs. Better to isolate the utils that require a Node environment from those that don't. These helpers are only used in the Babel plugin tests.
Are the Rust CI failures unrelated? Locally all the Rust tests pass, but |
@necolas has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Closed by 89fe7bc |
This PR upgrades jest from 26 to 29 and makes related changes. The unit tests pass; the
console.error
warnings seem to be pre-existing. Included some of them below.GraphQL fragments wrapped in a thunk
Errors in the test-only warnings module.
There were other problematic patterns in this code that I fixed (nesting
afterEach
within tests; doesn't play well withjest.resetModules
).Other