I want to set-up E2E tests with Cypress on a Vue.js application. When I start the Cypress test, it warns me that the Vue application (on localhost:8080) is not running, which suprised me a bit at first. As I thought that the Vue application would be started automatically (automagically? ;) with the start of the Cypress tests. But - as it turns out - it does not do this.
What I would like to do now, is to create a test script which will start the Cypress tests, the Vue.js front-end application, and the back-end Node.Js/Express application, in unison. (The front- and back-end application aren't very big at the moment, so starting them should not take that long. When they get bigger, I will most likely add stubs for the back-end calls.)
However, I cannot find out how to do this! I could start them by hand, but that seems quite cumbersome. And I cannot imagine that this could not be done with the help of some scripting or other code or configuration.
From what I've gathered, I think I need to create some kind of Webpack script to make this happen, but that is all I can find out (I have next to no Webpack experience, which doesn't help either...). How can i create a (shell?) script to accomplish this?
I believe you have to check the Cypress documentation - https://docs.cypress.io/guides/continuous-integration/introduction#Boot-your-server
Here is the excerpt from the content,
Many people approach this situation by running a command like the following:
npm start & cypress run // Do not do this
The problem is - what happens if your server takes time to boot? There is no guarantee that when the next command runs (cypress run
) that your web server is up and available. So your Cypress test may start and try to visit your local server before it is ready to be visited.
Solution
Luckily, there are some solutions for this. Instead of introducing arbitrary waits (like sleep 20) you can use a better option.
wait-on module
Using the wait-on module, you can block the cypress run
command from executing until your server has booted.
npm start & wait-on http://localhost:8080
cypress run