Uso de Docker y Cypress para Pruebas Automatizadas
Clase 25 de 29 • Curso de Cypress Avanzado
Contenido del curso
Clase 25 de 29 • Curso de Cypress Avanzado
Contenido del curso
David steven Abril Pulecio
Anderson David Chicaiza Tenesaca
David steven Abril Pulecio
Mario Alexander Vargas Celis
Joaquin Federico Demarchi
Updated 2025:
# Use the latest Cypress image with pre-installed browsers FROM cypress/browsers:node-22.14.0-chrome-133.0.6943.126-1-ff-135.0.1-edge-133.0.3065.82-1 USER root RUN npx cypress install # 📂 Set the working directory inside the container WORKDIR /app # 📦 Optimize dependency caching # First, copy package files separately to avoid unnecessary reinstallations COPY package.json package-lock.json /app/ RUN npm ci && npx cypress install # 🚀 Copy the entire project into the container COPY . /app # ✅ Verify Cypress installation to catch environment-related issues early RUN npx cypress verify # 📊 Ensure the Allure report script runs only if test results exist CMD ["npm", "run", "allure:report"]
cockerfile
From cypress/base:16 RUN mkdir /app WORKDIR /app COPY . /app RUN npm install --legacy-peer-deps RUN npm install --save-dev @babel/core @babel/preset-env babel-loader webpack RUN npx cypress install RUN $(npm bin)/cypress verify CMD ["npm", "run", "allure:report"]
Typo 😂
se crea el archivo
RUN mkdir /appWORKDIR /app copy . / app \# RUN npm install --legacy-peer-deps RUN npm install --save-dev @babel/core @babel/preset-env babel-loader webpack RUN npx cypress install \#RUN $(npm bin)/cypress verify CMD \["npm", "run", "allure-results"]``` docker-compose.yml ```ymlversion: '3.8'services: cypress\_compose: build: context: ./ dockerfile: ./Dockerfile volumes: - ./dockerReports:/app/allure-results``` iniciar docker: `docker login -u \<tu\_nombre\_de\_usuario> -p \<tu\_contraseña>` para iniciar la creacion de la imagen: `docker build .` Para iniciar la prueba se usa el siguiente código `docker-compose up` da los resultados en la sigiente dirección \*\*/dockerReports:/app/allure-results\*\*
Aquí dejo el paso a paso detallado https://www.notion.so/DOCKER-7f3fa55b1d844b418dcb95cf2ad44fd8?pvs=4