Skip to content

Instantly share code, notes, and snippets.

@yanmendes
Created August 2, 2019 20:39
Show Gist options
  • Save yanmendes/8500bea5660bd611996195288f6cd5ff to your computer and use it in GitHub Desktop.
Save yanmendes/8500bea5660bd611996195288f6cd5ff to your computer and use it in GitHub Desktop.
it('should print an error message in a failed submission', async () => {
axios.post.mockRejectedValue('not ok :(')
const { getByLabelText, getByText, findByText } = renderWithRedux(<App />)
const password = '123456'
const email = 'foo@bar.com'
fireEvent.input(getByLabelText('Email'), setValue(email))
fireEvent.input(getByLabelText('Password'), setValue(password))
fireEvent.input(getByLabelText('Confirm your password'), setValue(password))
fireEvent.click(getByText('Submit'))
const errorMessage = await findByText(/Something went wrong/)
expect(errorMessage).toBeVisible()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment