-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
@testing-library/react
version:^11.2.5
- Testing Framework and version:
jest@^26.6.3
- DOM Environment:
jest-environment-jsdom-sixteen@^1.0.3
Relevant code or config:
render(
<DndProvider backend={TestBackend}>
<Provider
snackbarUiStore={snackbarUiStore}
layoutComponentStore={layoutComponentStore}
activityTypeStore={activityTypeStore}
sceneStore={{}}
authStore={authStore}
configurationStore={configurationStore}
>
<TimelineForm activityTypeId={activityType.id} />
</Provider>
</DndProvider>
);
let mobileScene2 = await screen.findByTestId('mobile-screen-1');
userEvent.click(mobileScene2);
let revealsGroup = await screen.findByText('Reveals');
userEvent.click(revealsGroup);
const revealComponent = await screen.findByTestId('layout-component-18');
expect(revealComponent.className.includes('disabled')).toBeTruthy();
What you did:
I upgraded the @testing-library/react version from 9.4.0 to 11.2.5. After the upgrade, some of my tests fail.
Please refer to these 2 lines:
let revealsGroup = await screen.findByText('Reveals');
userEvent.click(revealsGroup);
I'm getting an element with text Reveals
which has an onClick
handler. And then fire the onClick event of it.
What happened:
The onClick event is not triggered after userEvent.click(revealsGroup);
But when I get this element twice, the onClick
event can be triggered correctly
This does not work:
let revealsGroup = await screen.findByText('Reveals');
userEvent.click(revealsGroup);
But this works:
let revealsGroup = await screen.findByText('Reveals');
userEvent.click(await screen.findByText('Reveals'));
Reproduction:
Please see the description above, cannot reproduce it in the Codesandbox
Problem description:
I'm assuming that the onClick
event is not attached to the element when the first call of the findByText
.
But when get this element again, the event is attached.