Skip to content

Instantly share code, notes, and snippets.

@mazikwyry
Created September 30, 2019 14:03
Show Gist options
  • Save mazikwyry/c5db71fcd9afca9c80fbe40b459f0082 to your computer and use it in GitHub Desktop.
Save mazikwyry/c5db71fcd9afca9c80fbe40b459f0082 to your computer and use it in GitHub Desktop.
React Testing Library - Given, When, Then
describe("when user inputs more characters ", () => {
const { getByLabelText, getByText } = render(<Component />);
const input = getByLabelText("label", { selector: "input" });
beforeEach(() => {
fireEvent.change(input, { target: { value: "new value" } });
});
it("displays suggestions", () => {
expect(getByText("new value")).toBeInTheDocument();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment