Created
January 19, 2021 17:09
-
-
Save jogilvyt/2d9773059b469e57a53661462cff5b7a to your computer and use it in GitHub Desktop.
End to end test for counter component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it("should initialise with the value stored in localStorage", () => { | |
// set the localStorage to a value other than 0 | |
localStorage.setItem("count", 15); | |
// render the App and check it initialises to the value in localStorage | |
render(<App />); | |
screen.getByText(/Number: 15/); | |
// click the increment button and check the localStorage is updated | |
const incrementButton = screen.getByText(/\+1/); | |
fireEvent.click(incrementButton); | |
screen.getByText(/Number: 16/); | |
expect(localStorage.getItem("count")).toBe("16"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment