Skip to content

Instantly share code, notes, and snippets.

@zidniryi
Created January 3, 2023 15:12
Show Gist options
  • Save zidniryi/c0dbb3381e5089015b45ce2cc0228fdb to your computer and use it in GitHub Desktop.
Save zidniryi/c0dbb3381e5089015b45ce2cc0228fdb to your computer and use it in GitHub Desktop.
App.test.tsx Unit Test Konsep Koding
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 />);
//simulate filling up the textbox
const personNameInput: HTMLInputElement = screen.getByRole("textbox");
await userEvent.type(personNameInput, "helo");
await waitFor(() => expect(personNameInput).toHaveValue("helo"))
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment