Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save moshfiqrony/b585e608ac86a22529c7357708f5d347 to your computer and use it in GitHub Desktop.
Save moshfiqrony/b585e608ac86a22529c7357708f5d347 to your computer and use it in GitHub Desktop.
test('Component rendered successfully', async () => {
axios.get.mockImplementationOnce(() => Promise.resolve({
status: 200,
data: {
name: 'Rony',
email: '[email protected]'
}
}))
const { container, getByTestId } = render(<ApiCallMock />);
expect(container.textContent).toMatch('Loading Data..')
await waitFor(() => expect(getByTestId('name').textContent).toMatch('Rony'))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment