Skip to content

Instantly share code, notes, and snippets.

@zidniryi
Created January 3, 2023 15:21
Show Gist options
  • Save zidniryi/05129a6dd320e02488407450cfcfcf3b to your computer and use it in GitHub Desktop.
Save zidniryi/05129a6dd320e02488407450cfcfcf3b to your computer and use it in GitHub Desktop.
userEvent test
import { render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import App from "./App";
describe("Render app", () => {
test("should change input value when user type", async () => {
render(<App />);
const textInput: HTMLInputElement = screen.getByTestId("input-form");
await userEvent.type(textInput, "helo");
await waitFor(() => expect(textInput).toHaveValue("helo"))
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment