-
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
Fix: switch IS_REACT_ACT_ENVIRONMENT in userEvent #1491
Fix: switch IS_REACT_ACT_ENVIRONMENT in userEvent #1491
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1491 +/- ##
==========================================
+ Coverage 98.12% 98.13% +0.01%
==========================================
Files 96 97 +1
Lines 5704 5747 +43
Branches 885 890 +5
==========================================
+ Hits 5597 5640 +43
Misses 107 107
☔ View full report in Codecov by Sentry. |
a7bbc19
to
84b85ff
Compare
@pierrezimmermannbam it seems to make sense to wrap However, I've noticed that original User Event actually does not seem to use |
I've found some clues about the original User Event, so since UE is not React specific it does not use The |
@mdjastrzebski that's interesting, I'll try to play with RTL's user event and see if I can reproduce the issue I encountered |
@pierrezimmermannbam is the issue you are trying to fix caused by this weird 130 ms delay introduced by React Native? If so then perhaps it would be good idea to just wrap that one I think the idea behind not wrapping |
I've done some testing with RTL using about the same test: it.only('is wrapped by act', async () => {
const consoleErrorSpy = jest.spyOn(console, 'error');
jest.useRealTimers();
const TestComponent = () => {
const [isVisible, setIsVisible] = React.useState(false);
React.useEffect(() => {
setTimeout(() => {
setIsVisible(true);
}, 100);
}, []);
return (
<>
<input placeholder="toto" />
{isVisible && <span>Visible</span>}
</>
);
};
render(<TestComponent />);
await userEvent.type(screen.getByPlaceholderText('toto'), 'al', {
delay: 200,
});
}); There is no act warning and what I've found is that the In our case it's not linked to the delay for the press out, any async code could be run while the user performs an action, as demonstrated in the test case I wrote in this PR, so I think it's a valid use case for using |
@pierrezimmermannbam More interesting, they seem to add a dummy |
@mdjastrzebski you're right, maybe we could try a similar approach with userEvent? This way we could make sure that every interaction is wrapped by act and prevent similar bugs from happening. Interesting also that they add a call to |
@pierrezimmermannbam afaik each interaction in UE is not wrapped by Not sure about the purpose of that |
994961d
to
bf309b4
Compare
@mdjastrzebski, looking again at this RFC on I updated the PR to mimic the behavior from RTL. We wrap every API from I was not too sure how to test this, I added a test case where an act warning would have been thrown if act environment wasn't set to false. I doesn't test every API but I don't really think it's worthwhile to write a test for every API. If this doesn't work as expected then we could add more tests if we feel they're valuable. I also kept the |
src/user-event/setup/setup.ts
Outdated
|
||
// This implementation is sourced from testing-library/user-event | ||
// https://github.com/testing-library/user-event/blob/7a305dee9ab833d6f338d567fc2e862b4838b76a/src/setup/setup.ts#L121 | ||
function wrapAndBindImpl<Impl extends (...args: any) => Promise<any>>( |
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.
Seems like we could move it to utils next to asyncWrapper
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.
Actually I moved the asyncWrapper
cause it's used also by waitFor
so I don't think it should be in the userEvent
folder. I don't see wrapAndBindImpl
being used elsewhere as it's directly tied to user event so I think it's in the right place
src/user-event/utils/asyncWrapper.ts
Outdated
|
||
let result: T; | ||
|
||
await act(async () => { |
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.
So, we only wrap in act
from React 16.9 to 17.x. Pls add code comment clarifing this
src/waitFor.ts
Outdated
import { ErrorWithStack, copyStackTrace } from './helpers/errors'; | ||
import { | ||
setTimeout, | ||
clearTimeout, | ||
jestFakeTimersAreEnabled, | ||
} from './helpers/timers'; | ||
import { checkReactVersionAtLeast } from './react-versions'; | ||
import { asyncWrapper } from './user-event/utils/asyncWrapper'; |
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.
If it's RNTL-wide helper, move it to general utils
from user-event/utils
src/user-event/utils/asyncWrapper.ts
Outdated
try { | ||
const result = await callback(); | ||
// Flush the microtask queue before restoring the `act` environment | ||
await flushMicroTasksLegacy(); |
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.
RTL has addtionally jest advance timers call: https://github.com/testing-library/react-testing-library/blob/c04b8f006c5a683d05c460c8ee1e2248d6f74350/src/pure.js#L49
Do you think we should add this as well?
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.
Not sure at all about that, I have no clue what it does. My thought process here was that we already had pretty much our own version of asyncWrapper
that we use for waitFor
and it seems to be working pretty well so I figured we might as well stick to that version. Maybe it could be worth investigating what difference it could make to get closer to RTL's implementation but I'd rather do that in another PR
@pierrezimmermannbam thanks for investigating that. I like that new implementation got in line with RTL,s one. I've left some minor comments to be addressed before merging. NB: From reading the code it seems like we are only focusing on supporting React 18, with React 17 logging some errors in the console, so it would be worth considering dropping official React 17 support in RNTL v13 #1505, since we aren't actually supporting it. |
bf309b4
to
a8d1f1a
Compare
@mdjastrzebski thanks for the review! I addressed your comments. I agree with you on React 17 support, there are some tests breaking and some errors logged as well on the main branch. And this PR also makes things a bit worse because it introduces overlapping act calls. We could fix that however by removing |
@mdjastrzebski could you please review when you have the time? It would be nice to have this pr in a release soon because this is currently a big blocker for user event |
@pierrezimmermannbam Thanks for pinging me, I've been pretty busy lately, but I'll try to review this in the following days. |
a8d1f1a
to
9617a43
Compare
(rebased on main) |
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 good to me!
This PR has been released v12.3.1 🚀 |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@testing-library/jest-native](https://togithub.com/testing-library/jest-native) | [`^5.4.2` -> `^5.4.3`](https://renovatebot.com/diffs/npm/@testing-library%2fjest-native/5.4.2/5.4.3) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@testing-library%2fjest-native/5.4.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@testing-library%2fjest-native/5.4.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@testing-library%2fjest-native/5.4.2/5.4.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@testing-library%2fjest-native/5.4.2/5.4.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [@testing-library/react-native](https://callstack.github.io/react-native-testing-library) ([source](https://togithub.com/callstack/react-native-testing-library)) | [`^12.2.2` -> `^12.4.3`](https://renovatebot.com/diffs/npm/@testing-library%2freact-native/12.2.2/12.4.3) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@testing-library%2freact-native/12.4.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@testing-library%2freact-native/12.4.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@testing-library%2freact-native/12.2.2/12.4.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@testing-library%2freact-native/12.2.2/12.4.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>testing-library/jest-native (@​testing-library/jest-native)</summary> ### [`v5.4.3`](https://togithub.com/testing-library/jest-native/compare/v5.4.2...v5.4.3) [Compare Source](https://togithub.com/testing-library/jest-native/compare/v5.4.2...v5.4.3) </details> <details> <summary>callstack/react-native-testing-library (@​testing-library/react-native)</summary> ### [`v12.4.3`](https://togithub.com/callstack/react-native-testing-library/releases/tag/v12.4.3) [Compare Source](https://togithub.com/callstack/react-native-testing-library/compare/v12.4.2...v12.4.3) #### Other - docs: jsdoc for Jest matchers by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1548](https://togithub.com/callstack/react-native-testing-library/pull/1548) **Full Changelog**: callstack/react-native-testing-library@v12.4.2...v12.4.3 ### [`v12.4.2`](https://togithub.com/callstack/react-native-testing-library/releases/tag/v12.4.2) [Compare Source](https://togithub.com/callstack/react-native-testing-library/compare/v12.4.1...v12.4.2) #### What's Changed ##### Improvements - feat: add option to pass `contentSize` and `layoutMeasurement` when calling `scrollTo` by [@​j-piasecki](https://togithub.com/j-piasecki) in [https://github.com/callstack/react-native-testing-library/pull/1543](https://togithub.com/callstack/react-native-testing-library/pull/1543) ##### Other - chore: remove renovate by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1539](https://togithub.com/callstack/react-native-testing-library/pull/1539) - chore: add release it by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1546](https://togithub.com/callstack/react-native-testing-library/pull/1546) #### New Contributors - [@​j-piasecki](https://togithub.com/j-piasecki) made their first contribution in [https://github.com/callstack/react-native-testing-library/pull/1543](https://togithub.com/callstack/react-native-testing-library/pull/1543) **Full Changelog**: callstack/react-native-testing-library@v12.4.1...v12.4.2 ### [`v12.4.1`](https://togithub.com/callstack/react-native-testing-library/releases/tag/v12.4.1) [Compare Source](https://togithub.com/callstack/react-native-testing-library/compare/v12.4.0...v12.4.1) #### What's Changed ##### New things - RFC/feat: default accessibility roles by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1490](https://togithub.com/callstack/react-native-testing-library/pull/1490) ##### Fixes - chore: fix extend-expect.d.ts types by internalizing them by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1536](https://togithub.com/callstack/react-native-testing-library/pull/1536) - fix: matcher Jest extensions by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1537](https://togithub.com/callstack/react-native-testing-library/pull/1537) - fix: user event add target prop by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1538](https://togithub.com/callstack/react-native-testing-library/pull/1538) ##### Other - chore: update & check example packages by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1528](https://togithub.com/callstack/react-native-testing-library/pull/1528) - docs: spell-check some docs by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1529](https://togithub.com/callstack/react-native-testing-library/pull/1529) - docs: rewrite How should I query? guide by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1531](https://togithub.com/callstack/react-native-testing-library/pull/1531) - docs: remove beta status for User Event by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1532](https://togithub.com/callstack/react-native-testing-library/pull/1532) - chore: deps update 2023-11-27 by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1533](https://togithub.com/callstack/react-native-testing-library/pull/1533) **Full Changelog**: callstack/react-native-testing-library@v12.4.0...v12.4.1 ### [`v12.4.0`](https://togithub.com/callstack/react-native-testing-library/releases/tag/v12.4.0) [Compare Source](https://togithub.com/callstack/react-native-testing-library/compare/v12.3.3...v12.4.0) #### What's Changed ### Features - Built-in Jest matchers - [documentation](https://callstack.github.io/react-native-testing-library/docs/jest-matchers) - [migration guide from legacy Jest Native matchers](https://callstack.github.io/react-native-testing-library/docs/migration-jest-native) ### Contributors for this feature 👏👏👏 - `toHaveTextContent` matcher [#​1461](https://togithub.com/callstack/react-native-testing-library/issues/1461) by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) - `toBeEmptyElement` matcher [#​1462](https://togithub.com/callstack/react-native-testing-library/issues/1462) by [@​kyawthura-gg](https://togithub.com/kyawthura-gg) - `toHaveDisplayValue` matcher [#​1463](https://togithub.com/callstack/react-native-testing-library/issues/1463) by [@​jaworek](https://togithub.com/jaworek) & [@​mdjastrzebski](https://togithub.com/mdjastrzebski) - `toBeVisible` matcher [#​1465](https://togithub.com/callstack/react-native-testing-library/issues/1465) by [@​thiagobrez](https://togithub.com/thiagobrez) - `toBeEnabled` & `toBeDisabled` matchers [#​1469](https://togithub.com/callstack/react-native-testing-library/issues/1469) by [@​jaworek](https://togithub.com/jaworek) - `toHaveProp` matcher [#​1477](https://togithub.com/callstack/react-native-testing-library/issues/1477) by [@​AntoineThibi](https://togithub.com/AntoineThibi) - `toBeChecked` & `toBePartiallyChecked` matchers [#​1479](https://togithub.com/callstack/react-native-testing-library/issues/1479) by [@​kyawthura-gg](https://togithub.com/kyawthura-gg) - `toHaveStyle` matcher [#​1487](https://togithub.com/callstack/react-native-testing-library/issues/1487) by [@​marcinkornek](https://togithub.com/marcinkornek) - `toBeSelected` matcher [#​1488](https://togithub.com/callstack/react-native-testing-library/issues/1488) by [@​AntoineThibi](https://togithub.com/AntoineThibi) - `toBeBusy` matcher [#​1493](https://togithub.com/callstack/react-native-testing-library/issues/1493) by [@​hduprat](https://togithub.com/hduprat) - `toContainElement` matcher [#​1495](https://togithub.com/callstack/react-native-testing-library/issues/1495) by [@​siepra](https://togithub.com/siepra) - `toHaveAccessibilityValue` matcher [#​1496](https://togithub.com/callstack/react-native-testing-library/issues/1496) by [@​tarunrajput](https://togithub.com/tarunrajput) - `toBeExpanded` & `toBeCollapsed` matchers [#​1497](https://togithub.com/callstack/react-native-testing-library/issues/1497) by [@​siepra](https://togithub.com/siepra) - `toHaveAccessibleName` matcher [#​1509](https://togithub.com/callstack/react-native-testing-library/issues/1509) by [@​anishamalde](https://togithub.com/anishamalde) - Special thanks to [@​pierrezimmermannbam](https://togithub.com/pierrezimmermannbam) for helping with code reviews! **Full Changelog**: callstack/react-native-testing-library@v12.3.3...v12.4.0 ### [`v12.3.3`](https://togithub.com/callstack/react-native-testing-library/releases/tag/v12.3.3) [Compare Source](https://togithub.com/callstack/react-native-testing-library/compare/v12.3.2...v12.3.3) #### What's Changed ##### Features: - feat: toHaveAccessibleName matcher by [@​anishamalde](https://togithub.com/anishamalde) in [https://github.com/callstack/react-native-testing-library/pull/1509](https://togithub.com/callstack/react-native-testing-library/pull/1509) (not yet public, will be exposed publically in v12.4.0) ##### Fixes - fix: change broken hyperlink in README.md by [@​jovanimal](https://togithub.com/jovanimal) in [https://github.com/callstack/react-native-testing-library/pull/1520](https://togithub.com/callstack/react-native-testing-library/pull/1520) ##### Other improvements & chores - docs: Jest matchers docs by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1506](https://togithub.com/callstack/react-native-testing-library/pull/1506) - chore: modern yarn (4.0) by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1517](https://togithub.com/callstack/react-native-testing-library/pull/1517) - chore: enable Yarn 4 on CI by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1525](https://togithub.com/callstack/react-native-testing-library/pull/1525) - chore: expose Jest Native exports by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1522](https://togithub.com/callstack/react-native-testing-library/pull/1522) - Dependabot/npm and yarn/callstack/eslint config 14.0.0 by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1526](https://togithub.com/callstack/react-native-testing-library/pull/1526) #### New Contributors - [@​jovanimal](https://togithub.com/jovanimal) made their first contribution in [https://github.com/callstack/react-native-testing-library/pull/1520](https://togithub.com/callstack/react-native-testing-library/pull/1520) - [@​anishamalde](https://togithub.com/anishamalde) made their first contribution in [https://github.com/callstack/react-native-testing-library/pull/1509](https://togithub.com/callstack/react-native-testing-library/pull/1509) **Full Changelog**: callstack/react-native-testing-library@v12.3.2...v12.3.3 ### [`v12.3.2`](https://togithub.com/callstack/react-native-testing-library/releases/tag/v12.3.2) [Compare Source](https://togithub.com/callstack/react-native-testing-library/compare/v12.3.1...v12.3.2) #### What's Changed Improvements: - Adds typedefs for pure by [@​chriserickson](https://togithub.com/chriserickson) in [https://github.com/callstack/react-native-testing-library/pull/1516](https://togithub.com/callstack/react-native-testing-library/pull/1516) #### New Contributors - [@​chriserickson](https://togithub.com/chriserickson) made their first contribution in [https://github.com/callstack/react-native-testing-library/pull/1516](https://togithub.com/callstack/react-native-testing-library/pull/1516) **Full Changelog**: callstack/react-native-testing-library@v12.3.1...v12.3.2 ### [`v12.3.1`](https://togithub.com/callstack/react-native-testing-library/releases/tag/v12.3.1) [Compare Source](https://togithub.com/callstack/react-native-testing-library/compare/v12.3.0...v12.3.1) #### What's Changed ### Features - UserEvent `scrollBy` [@​siepra](https://togithub.com/siepra) in [https://github.com/callstack/react-native-testing-library/pull/1445](https://togithub.com/callstack/react-native-testing-library/pull/1445) ### Fixes - fix: properly manage IS_REACT_ACT_ENVIRONMENT in UserEvent by [@​pierrezimmermannbam](https://togithub.com/pierrezimmermannbam) in [https://github.com/callstack/react-native-testing-library/pull/1491](https://togithub.com/callstack/react-native-testing-library/pull/1491) #### New Contributors - [@​marcinkornek](https://togithub.com/marcinkornek) made their first contribution in [https://github.com/callstack/react-native-testing-library/pull/1487](https://togithub.com/callstack/react-native-testing-library/pull/1487) - [@​meatnordrink](https://togithub.com/meatnordrink) made their first contribution in [https://github.com/callstack/react-native-testing-library/pull/1494](https://togithub.com/callstack/react-native-testing-library/pull/1494) **Full Changelog**: callstack/react-native-testing-library@v12.3.0...v12.3.1 ### [`v12.3.0`](https://togithub.com/callstack/react-native-testing-library/releases/tag/v12.3.0) [Compare Source](https://togithub.com/callstack/react-native-testing-library/compare/v12.2.2...v12.3.0) #### Features - ARIA props (`role` & `aria-*`) support: - feat: support aria-hidden prop by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1474](https://togithub.com/callstack/react-native-testing-library/pull/1474) - feat: support `role` prop by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1476](https://togithub.com/callstack/react-native-testing-library/pull/1476) - feat: support `aria-label` and `aria-labelledby` props by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1475](https://togithub.com/callstack/react-native-testing-library/pull/1475) - feat: `aria-*` state props by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1478](https://togithub.com/callstack/react-native-testing-library/pull/1478) - feat: `aria-modal` support by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1481](https://togithub.com/callstack/react-native-testing-library/pull/1481) - feat: `aria-value*` props support by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1480](https://togithub.com/callstack/react-native-testing-library/pull/1480) - Jest Native matcher migration to RNTL (work in progress): - feature: Jest matchers core by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1454](https://togithub.com/callstack/react-native-testing-library/pull/1454) - feat: add Jest matchers utils by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1464](https://togithub.com/callstack/react-native-testing-library/pull/1464) - feat: `toBeEmptyElement` matcher by [@​kyawthura-gg](https://togithub.com/kyawthura-gg) in [https://github.com/callstack/react-native-testing-library/pull/1462](https://togithub.com/callstack/react-native-testing-library/pull/1462) - feat: `toHaveDisplayValue` matcher by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1463](https://togithub.com/callstack/react-native-testing-library/pull/1463) - feat: `toHaveTextContent()` matcher by [@​mdjastrzebski](https://togithub.com/mdjastrzebski) in [https://github.com/callstack/react-native-testing-library/pull/1461](https://togithub.com/callstack/react-native-testing-library/pull/1461) - feat: `toBeVisible` matcher by [@​thiagobrez](https://togithub.com/thiagobrez) in [https://github.com/callstack/react-native-testing-library/pull/1465](https://togithub.com/callstack/react-native-testing-library/pull/1465) - feat: `toBeDisabled` matcher by [@​jaworek](https://togithub.com/jaworek) in [https://github.com/callstack/react-native-testing-library/pull/1469](https://togithub.com/callstack/react-native-testing-library/pull/1469) - feat: `toHaveProp` matcher by [@​AntoineThibi](https://togithub.com/AntoineThibi) in [https://github.com/callstack/react-native-testing-library/pull/1477](https://togithub.com/callstack/react-native-testing-library/pull/1477) - feat: `toBeChecked` & `toBePartiallyChecked` matcher by [@​kyawthura-gg](https://togithub.com/kyawthura-gg) in [https://github.com/callstack/react-native-testing-library/pull/1479](https://togithub.com/callstack/react-native-testing-library/pull/1479) Note: Jest matchers are work in progress and haven't yet been officially released. You can track progress of this initiative in [#​1468](https://togithub.com/callstack/react-native-testing-library/issues/1468). #### New Contributors - [@​M-Tilley-SA](https://togithub.com/M-Tilley-SA) made their first contribution in [https://github.com/callstack/react-native-testing-library/pull/1460](https://togithub.com/callstack/react-native-testing-library/pull/1460) - [@​kyawthura-gg](https://togithub.com/kyawthura-gg) made their first contribution in [https://github.com/callstack/react-native-testing-library/pull/1462](https://togithub.com/callstack/react-native-testing-library/pull/1462) - [@​friederbluemle](https://togithub.com/friederbluemle) made their first contribution in [https://github.com/callstack/react-native-testing-library/pull/1470](https://togithub.com/callstack/react-native-testing-library/pull/1470) - [@​thiagobrez](https://togithub.com/thiagobrez) made their first contribution in [https://github.com/callstack/react-native-testing-library/pull/1465](https://togithub.com/callstack/react-native-testing-library/pull/1465) - [@​AntoineThibi](https://togithub.com/AntoineThibi) made their first contribution in [https://github.com/callstack/react-native-testing-library/pull/1477](https://togithub.com/callstack/react-native-testing-library/pull/1477) **Full Changelog**: callstack/react-native-testing-library@v12.2.2...v12.3.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on Monday" in timezone America/Los_Angeles, Automerge - "after 5pm,every weekend" in timezone America/Los_Angeles. 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/valora-inc/wallet). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMjEuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEyMS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Summary
I noticed on one of my project where I migrated
fireEvent
touserEvent
that I got an act warning once when usinguserEvent.press
. What I found is that it was due to the fact that thewait
function does not useact
, although it advances timers. This PR fixes that issue by usingact
inwait
.Test plan
I added a test case but it's not perfect. Before the fix there was a warning in the console but the test still worked. Because
wait
is async, the useEffect is still run even when not using act . The only solution I found to get the test to fail was to spy onconsole.error
and make sure it's not called.