Reputation: 10581
We have a frontend app that we serve and we want to do e2e tests on it on a CI server. What is the best approach to do that?
The whole test should run on a non-gui CI, executable with a single command.
What would come to my mind is something like this:
concurrently "npm run serve" "npx cypress run"
But this seems to add a huge and uneccessary overhead. Plus I somehow have to make sure that the tests don't execute before the app is actually served.
Upvotes: 1
Views: 2524
Reputation: 2123
How about automating all e2e workflows with endly e2e test runner.
Starting app and delegating testing to cypress may look like the following
@test.yaml
pipeline:
test:
multiAction: true
startApp:
async: true
action: exec:run
commands:
- npm run serve
runTest:
async: true
action: exec:run
commands:
- wait-on http://localhost:8000 && npm run cypress
Upvotes: 0
Reputation: 18099
As mentioned in the Cypress continuous integration docs, you can use a npm package called wait-on to wait for your server before running Cypress:
npm run serve & # run this in the background
wait-on http://localhost:8000 && npm run cypress
Upvotes: 1
Reputation: 3741
Not a definite solution, but just some thoughts. We are using a bash script which results in starting the tests with one command. In that bash script we have this:
# environment variables
export HOME=${PWD}
yarn install
./node_modules/.bin/cypress install
./node_modules/.bin/cypress verify
./node_modules/.bin/cypress run ${SMOKETEST}
Upvotes: 0