You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{render,screen}from"@testing-library/react";importuserEventfrom"@testing-library/user-event";import{UncontrolledDropdown}from"./uncontrolled-dropdown";it("renders without crashing",async()=>{constuser=userEvent.setup();render(<UncontrolledDropdown/>);awaituser.click(screen.getByText("Trigger"));expect(screen.getByRole("menu")).toBeInTheDocument();});
And the following test will fail. It will fail to query for an element with role 'menu'.
import{render,screen}from"@testing-library/react";importuserEventfrom"@testing-library/user-event";import{UncontrolledDropdown}from"./uncontrolled-dropdown";it("renders without crashing",async()=>{constuser=userEvent.setup();render(<UncontrolledDropdown/>);awaituser.click(screen.getByText("Trigger"));expect(screen.getByRole("menu")).toBeInTheDocument();});
Expected behavior
Whether the component is controlled or not should not impact the test.
Bug report
Current Behavior
The dropdown will open as expected when its open state is not controlled.
However, when the state is controlled,
I have made implementation and test for each case.
And the following test passes.
Here is the controlled version
And the following test will fail. It will fail to query for an element with role 'menu'.
Expected behavior
Whether the component is controlled or not should not impact the test.
Reproducible example
CodeSandbox
Suggested solution
Not really sure what's going on here.
Additional context
I have tried to mock PointerEvent as Suggested by #856, but it doesn't fix the issue.
Your environment
The text was updated successfully, but these errors were encountered: