How to run Cypress from Docker?

Viewed 1235

I'm trying to run Cypress tests head(lessly) with Docker. From tutorial I've followed I've got this command:

docker run -it -v ~/tdd/services/cypress:/cypress -w /cypress --entrypoint=cypress cypress/included:4.9.0 run

This throws:

Can't run because no spec files were found.

We searched for any files inside of this folder:

/cypress/cypress/integration

I keep Cypress directory with all test specs and cypress.json file in absolute path ~/tdd/services/cypress which is included in the command so Cypress knows what files to add to the container.

structure of the cypress directory:

cypress/
    integration/
    cypress.json
    package.json

Getting error anyway. Can anyone more rounded in Cypress & Docker assist me on this ?

Dockerfile:

FROM cypress/included:4.9.0

WORKDIR /
RUN rm -rf /cypress/integration
ADD integration /cypress/integration
COPY package.json /cypress/package.json
RUN npm install randomstring --save
RUN cypress run
1 Answers

Your cypress structure should look like this:

cypress/
    integration/
cypress.json
package.json

Or if you want to keep it as you mentioned above because of reasons, then specify this in cypress.json file: "integrationFolder": "integration". This will override the default cypress/integration path value, tho I would suggest the first solution.

Related