Skip to content

Instantly share code, notes, and snippets.

@nedgrady
Created November 18, 2024 23:18
Show Gist options
  • Save nedgrady/ac0f724339bbae62819cc2197629b8b0 to your computer and use it in GitHub Desktop.
Save nedgrady/ac0f724339bbae62819cc2197629b8b0 to your computer and use it in GitHub Desktop.
test("The button callback is called when the button is clicked", () => {
const onClickMock = vi.fn()
const { getByRole } = render(<CustomButton onClick={onClickMock} text="Click me" />)
userEvent.click(getByRole("button", { name: "Click me" }))
expect(onClickMock).toHaveBeenCalled
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment