Cypress + Docker + Codeship Pro = ❤️

Codeship Status for cypress-io/cypress-example-docker-codeship renovate-app badge

Running your Cypress E2E tests on Codeship Pro CI is very simple. You can either start with a base image cypress/base with all dependencies.

  1. Create test image

Use Dockerfile to build a test image. If you use cypress/base image you would need to install NPM dependencies that includes Cypress.

FROM cypress/base:10
WORKDIR /app
# 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
  1. Define Codeship build step

Use codeship-services.yml file to build cypress/cypress-codeship-test image (from the above Dockerfile).

cypress-codeship-test:
  build:
    image: cypress/cypress_codeship_test
    dockerfile: Dockerfile
  1. Define test steps

Use codeship-steps.yml file to use the built image and run one or more E2E tests in parallel or in sequence.

- name: "Cypress E2E tests"
  service: cypress-codeship-test
  command: npm run cy:run

The cy:run command is an NPM script defined in package.json

{
    "scripts": {
        "cy:run": "cypress run"
    }
}

Now push the changes to the repo, and watch Codeship run

Codeship run

Recording

The tests are recorded on Cypress Dashboard. The CYPRESS_RECORD_KEY is encrypted following Codeship Pro documentation

Happy testing

If you find problems with Cypress and CI, please