Cypress is a nice JavaScript end-to-end testing framework.
It could also spy into what http requests have been sent, wait for their response and assert the response. The documentation for this functionality can be found on the Network Requests doc page.
For me it was very useful as my machine is really slow hosting the server in the docker, and I have to allow a waiting time before going to the next step. cy.wait(8000)
is an easy walk around but is neither reliable nor elegant. So instead, I spied on the requests and wait for it to get a response, and proceed to the next step when I get the response wanted.
Here is the code I used to spy on requests:
1 | cy.server() |
.as()
gives the request an alias that could be referred to later.
1 | cy.visit('http://localhost:3000') |