Skip to content

Instantly share code, notes, and snippets.

@gasserkl
Created September 8, 2021 11:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save gasserkl/a9be2c5b48aab84846c45b5efff33153 to your computer and use it in GitHub Desktop.
it("renders a login form", () => {
// when
render(<App />);
// then: the login-form elements should be rendered
const loginForm = screen.getByRole("form");
const usernameInput = within(loginForm).getByPlaceholderText("Username");
const passwordInput = within(loginForm).getByPlaceholderText("Password");
const loginButton = within(loginForm).getByRole("button");
expect(loginForm).toBeInTheDocument();
expect(usernameInput).toBeInTheDocument();
expect(passwordInput).toBeInTheDocument();
expect(loginButton).toBeInTheDocument();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment