I'm writing test code with Jest and React Testing Library.
The code passes but it shows the error "Error: connect ECONNREFUSED 127.0.0.1:80".
This is the code.
describe('Purchase button', () => {
test('It should be working and move to complete page', async () => {
:
// Push 'Submit' button
act(() => {
fireEvent.click(getByText(/Submit/));
})
expect(spyAPI).toBeCalledWith(`${id}`);
// Check moving to complete page.
await waitFor(() => {
expect(getByText(/Thank you, you have purchased/)).toBeInTheDocument();
})
:
If the last line is commented out like the following, the error message is not there.
/*
await waitFor(() => {
expect(getByText(/Thank you, you have purchased/)).toBeInTheDocument();
})
*/