'How to create Dockerfile for Cypress tests with Node.js server

I have my cypress tests, but also, I have some services that works with remote database and, most important, Node.js server that I need to send emails in case of error. The structure of project looks like this:

enter image description here

I have created Dockerfile, but it doesn't seem to be working:

FROM cypress/included:9.4.1

WORKDIR /e2e-test

COPY package.json /e2e

RUN npm install

COPY . .

VOLUME [ "/e2e-test" ]

CMD ["npm", "run", "tests"]

So, what I need to do is mount this folder to docker container and then, by npm run tests run local server (NOTE: I need this local server only for nodemailer, because it works only on server side).

Also, script npm run tests looks like this. This script runs server and then tests - "tests": "npm run dev & npx cypress run"

How can I implement this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source