Earlier I wrote a blog post
about how easy it is to integrate and run cypress within your CI environment. Quick. Easy. Quite painless.
Here are but a few examples!Gitlab
- npm install
- $(npm bin)/cypress run
name: Running E2E tests
command: cypress run --reporter junit --reporter-options "mochaFile=results/my-test-output.xml"
# explanation of the "docker run" command line arguments
# -it = interactive terminal
# -v $PWD:/e2e = map current folder to /e2e inside the container
# -w /e2e = set working directy to /e2e
# $@ = pass any arguments to this script to the Cypress command
# like "./cy-run.sh --record"
# Docker image "cypress/included:3.2.0" has its entrypoint
# set to "cypress run" by default
docker run -it -v $PWD:/e2e -w /e2e cypress/included:6.2.1 $@
Want to build custom Test Images beforehand? Create a Docker file!
# Copy our test page and test files
COPY index.html ./
COPY cypress.json ./
COPY package.json ./
COPY cypress ./cypress
# Install npm dependencies, can also use "npm ci"
RUN npm install
For more information, checkout the official Cypress article
on using Docker! Advanced Gitlab
Here at Aspera, we utilize Gitlab for our day-to-day builds and test automation. There are so many options when it comes to configuring your CI to run tests the way you want. With cypress images built so reliably, you can focus on building up your automation setup. Here's a partial example of how you can utilize the power of Gitlab CI to run tests the way you want.
# cypress/included images have entrypoint set to "cypress"
# which conflicts with GitLab CI wrapper shell script
- export CYPRESS_CI_JOB_ID=$CI_JOB_ID
- npm install
expire_in: 3 days
- npm run cypress:run