Open JunyeongChoi0 opened 4 months ago
Same here. "CLICK" gets logged but the test fails:
import { fireEvent, render, screen } from "@testing-library/react"
import userEvent from "@testing-library/user-event"
const user = userEvent.setup()
test('click', async () => {
render(
<div>
<label htmlFor="checkbox" onClick={() => console.log("CLICK")}>Check</label>
<input id="checkbox" type="checkbox" />
</div>,
)
await user.click(screen.getByText('Check'))
// fireEvent.click(screen.getByText('Check'))
expect(screen.getByLabelText('Check')).toBeChecked()
})
Reproduction example
https://codesandbox.io/p/devbox/elated-gould-h5tv93
Prerequisites
<label><span>label</span><input type="checkbox" /></label>
Expected behavior
The checkbox should be checked.
Actual behavior
The checkbox is still unchecked.
User-event version
14.5.2
Environment
Testing Library framework:
JS framework:
Test environment:
DOM implementation:
Additional context
No response