-
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
Add missing act() in tests and fix other test issues #15636
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 0cc47cf:
|
Perf AnalysisNo significant results to display. All results
Perf Analysis (Fluent)Perf comparison
Perf tests with no regressions
|
Asset size changesUnable to find bundle size details for Baseline commit: cfff925 Possible causes
Recommendations
|
0e60b0f
to
84e2f7a
Compare
# Conflicts: # packages/react-internal/src/components/Calendar/Calendar.test.tsx # packages/react-internal/src/components/DatePicker/DatePicker.test.tsx
🎉 Handy links: |
Pull request checklist
$ yarn change
Description of changes
Noticed while working on another PR that several components in react-internal were logging errors from their tests about missing
act()
usage, but those errors weren't causing builds to fail. So this PR adds the missingact()
wrappers AND fixes the logging so that errors like this will cause failures in the future. (The issue was that errors thrown in certain async scenarios were being eaten by our mockAsync
implementation rather than thrown.)I also made some fixes to scripts/jest/jest-setup.js to reduce the verbosity of
act()
-related errorsWhile working on the test fixes, I noticed that many places were using
expect(...).toBeDefined()
in a way that seemed to assume that the assertion would fail fornull
as well asundefined
, which is NOT the case (it only checks forundefined
). Depending on the circumstances, the fix is to use eitherexpect(...).toBeTruthy()
orexpect(...).not.toBeNull()
. I did a search and updated all the places where the usage seemed incorrect.