-
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
Run tests with React 19 RC.1 and adjust tests accordingly #12140
Conversation
✅ Docs Preview ReadyNo new or changed pages found. |
|
commit: |
size-limit report 📦
|
() => | ||
useQuery(query, { | ||
onCompleted, | ||
notifyOnNetworkStatusChange: true, | ||
pollInterval: 110, | ||
pollInterval: 200, |
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.
Interweaving things that are not part of the renderStream (expect(onCompleted).toHaveBeenCalledTimes(1)
) with the timing of the renderStream can make up for a flaky test.
In the long run, this should probably be refactored and the call count should become part of the snapshot.
In the meantime, I'm raising the interval here to prevent this test from being flaky.
@@ -85,7 +85,6 @@ const standardReact17Config = { | |||
"^react-dom$": "react-dom-17", | |||
"^react-dom/server$": "react-dom-17/server", | |||
"^react-dom/test-utils$": "react-dom-17/test-utils", | |||
"^@testing-library/react$": "@testing-library/react-12", |
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 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.
Thanks for updating all those!
@@ -63,6 +63,13 @@ export function setupVariablesCase() { | |||
return { mocks, query }; | |||
} | |||
|
|||
export function slowDownMocks<T extends MockedResponse<unknown>[]>( |
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.
export function slowDownMocks<T extends MockedResponse<unknown>[]>( | |
export function addDelayToMocks<T extends MockedResponse<unknown>[]>( |
It took me a bit to realize what this helper did since "slow down" is not generally something you want in your tests if you can help it. Could you name this addDelayToMocks
instead so that it makes it a bit more obvious its intent?
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.
Good call :)
useTrackRenders, | ||
} from "@testing-library/react-render-stream"; | ||
|
||
const IS_REACT_19 = React.version.startsWith("19"); | ||
|
||
afterEach(() => wait(10)); |
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.
any chance you could add a comment here to explain why this is needed?
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.
That comment would be // ooops
^^ I think that's not necessary.
Co-authored-by: Jerel Miller <[email protected]>
Co-authored-by: Jerel Miller <[email protected]>
Co-authored-by: Jerel Miller <[email protected]>
If we are not in a render-streaming test
render
torenderAsync
for suspense testsact
withactAsync
for suspense testsIf we are in a render-streaming test
await
disableActEnvironment
on a per-test basisact
calls in these testsBefore we merge this, we should review testing-library/react-render-stream-testing-library#10 and release it as 2.0 (released as 2.0 alpha for now)
This currently builds on top of a PR in RRSTL and inlines
actAsync
, andrenderAyncHook
from testing-library/react-testing-library#1365 while providing a simple wrapper asrenderAsync
.Please also review testing-library/react-render-stream-testing-library#10
I will still investigate using https://github.com/eps1lon/codemod-missing-await-act, but do so in a separate PR