-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[React@18] Upgrade @testing-library/react
#198918
Changes from 7 commits
b5fdc8b
d509329
2bdd98d
bf93455
fb7b8e1
1320f6d
f168f32
722a63f
09573a7
989fb10
0a9c257
ed2d951
886fa4e
3c08a79
2229964
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
export {}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,15 @@ import { configure } from '@testing-library/react'; | |
|
||
// instead of default 'data-testid', use kibana's 'data-test-subj' | ||
configure({ testIdAttribute: 'data-test-subj', asyncUtilTimeout: 4500 }); | ||
|
||
/* eslint-env jest */ | ||
|
||
jest.mock('@testing-library/react', () => { | ||
const actual = jest.requireActual('@testing-library/react'); | ||
|
||
return { | ||
...actual, | ||
render: (ui, options) => actual.render(ui, { ...options, legacyRoot: true }), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forcing There is no global configuration for this option, so we have to do this mocking workaround to adjust the default. Event after upgrade of the react packages to React@18 it would make sense to keep this option as it until we start upgrading to the Concurrent Mode. We will likely come of a gradual transition plan in parallel with the runtime. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah same thing here as above, I feel at minimum we need a comment to track this. |
||
renderHook: (render, options) => actual.renderHook(render, { ...options, legacyRoot: true }), | ||
}; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -403,10 +403,10 @@ describe('CheckAll', () => { | |
|
||
// simulate the wall clock advancing | ||
for (let i = 0; i < totalIndexNames + 1; i++) { | ||
await waitFor(() => {}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test seem to rely on some very specific internal timings that apparently have changed. I found that adding another waitFor fixes the tests. Feel free to take a look and contribute to make it more robust |
||
act(() => { | ||
jest.advanceTimersByTime(1000 * 10); | ||
}); | ||
|
||
await waitFor(() => {}); | ||
} | ||
}); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
We're just mocking this with an
{}
, this API from React@18 won't be used because we're forcinglegacyRoot:true
. Just need to it help to resolve the modules. This mock can be removed with an upgrade to React@18