Can not get cypress to work in docker container

Viewed 128

I want to run cypress in docker container and for this purpose i created. For this i followed some guides and tutorials

  1. e2e directory that has Dockerfile
FROM cypress/base:14
WORKDIR /app

# dependencies will be installed only if the package files change
COPY package.json .
COPY cypress.json .

RUN npm install
RUN npx cypress open
RUN npx cypress verify
cypress.json 
  {
    "baseUrl": "http://localhost:3000",
    "reporter": "junit",
    "reporterOptions": {
      "mochaFile": "cypress/results/output.xml"
    }
  }
package.json
{
    "name": "e2e",
    "version": "1.0.0",
    "description": "Cypress tests",
    "main": "index.js",
    "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "private": true,
    "devDependencies": {
      "cypress": "9.5.0"
    }
}

and .npmrc

registry=http://registry.npmjs.org/
save-exact=true
progress=false
package-lock=true
  1. modified docker-compose.yml at the root to be

    version: '3.8'
    services:
    nextjsApp: 
        // rest    
    cypress:
        image: "cypress/included:3.2.0"
        depends_on:
          - nextjs
        environment:
          - CYPRESS_baseUrl=http://nextjs:3000
        working_dir: /e2e
        command: npx cypress run
        volumes:
          - ./:/e2e
    networks:
      backend:
        external: true```
    
    

Running docker-compose build does not cause or show any errors But when i run docker-compose up i get

cypress_1  | Could not find any tests to run.
cypress_1  | 
cypress_1  | We looked but did not find a cypress.json file in this folder: /e2e

How can this be solved ?

0 Answers
Related