-
Notifications
You must be signed in to change notification settings - Fork 272
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
Switch to IS_REACT_ACT_ENVIRONMENT instead of act when needed when using react 18 #1131
Conversation
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.
@AugustinLF big WOW for creating this PR 🚀
I've done some cursory review and left few comments, I plan to dig a bit deeper into that, as the PR is quite complex.
d5e8513
to
32b9288
Compare
@mdjastrzebski I've updated the PR with your feedback, let me know if you need anything else :) |
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.
Almost there 🚀 , looking forward to merging that :-)
a4ceafc
to
729626a
Compare
We're good @mdjastrzebski :) |
@AugustinLF It seems I've broken build by pushing a simple commit that adds one line for formatting. Can you add some minimal commit so that the build is triggered as your user? |
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.
Looks great! Though I've broke the build by adding an empty line for formatting purpose.
@mdjastrzebski fixed, added an empty commit! |
I wish React team documented this better. This horrific experience for testing library authors. |
Yeah, the documentation was there in the WG, but not in the main release notes, so a bit sketchy. @mdjastrzebski what do you think of creating an RC release of that? I'm currently working on our react 18 upgrade and that'd be some good battle testing. |
Going through RC sounds good, for extra safety. From our analysis of both RTL and React 18 code with @thymikee , we came to conclusion that In short: |
Yes. But on top of that we updated the implementation of waitFor: // from
let result: T;
await act(async () => {
result = await waitForInternal(expectation, optionsWithStackTrace);
});
// to
await waitForInternal(expectation, optionsWithStackTrace); |
@AugustinLF we will make the release after the weekend, as I need @thymikee for npm publish access rights. |
🎉 This PR is included in version 11.2.0 🎉 |
Closes #1093. Implementation is copied from testing-library/react-testing-library#1031
Without the react 17/18 branches (i.e only using the new API), tests pass but are full of
console.error
related toact
andasync act
. With his new implementation, everything passes (including the new tests that used to fail on react 18), without calls toconsole.error
.