continuous-integration - How can I run Fullstack E2E Tests in CI (Gitlab)
问题描述
I have a webapp consisting of - A frontend repository (Angular 8) - A backend repository (Node.js/NestJS 6)
I use Gitlab as SCM provider, docker registry and CI/CD tool. Installing, linting, testing (unit) and building already works with CI.
Now I want to introduce E2E tests which I added within the frontend repository using Cypress.
For the tests to work, I need to - run the backend (using docker-compose) including a S3 mock and the DB (mongo) - insert demo data to the backend (got a script for that) - run the frontend pointing to the backend API - run the cypress tests
The question that I have is: How can I run the dockerized backend including dependencies within the CI stage so that I have a backend instance to run the e2e tests aginst?
I already tried running the backend via docker-compose within the stage. This lead to the containers getting started but they were not accessible from within the gitlab-runner container.
This is a stage within the frontend repo .gitlab-ci.yml:
e2e:
image: docker:stable
stage: e2e
script:
- apk add --no-cache py-pip python-dev libffi-dev openssl-dev gcc libc-dev make nodejs npm git curl
- pip install docker-compose
- npm install -g wait-on spa-http-server forever
- docker-compose up -d
- wait-on http://localhost:4000/api/ && curl -X POST http://localhost:4000/global/createDemoData
- npm run build
- forever start -c http-server dist/XXX/ -p 4200 --push-state
- wait-on http://localhost:4200 && npm run e2e-ci
- forever stopall
- docker-compose down
解决方案
推荐阅读
- scala - Scala MurmurHash3 库与 Spark Hash 函数不匹配
- sql - 使用 WHERE 条件显示 2 个列出/GROUP BY 值的总和
- powershell - PowerShell - 如果 X 列中的值存在,则将值从源 CSV 返回到 CSV
- permissions - 为 inno setup 创建一个新用户组
- node.js - pdfkit:生成的 pdf 文档不呈现印地语文本
- sql - 如何在 SQL 中循环用户定义的数据类型并将参数传递给过程
- php - When a bundle product is in cart remove child components from cart in Woocommerce
- github - 在 Azure 管道中使用 git 命令时出错
- javascript - how can i get dicom tools to work with uploaded images using cornerstoneWADOImageLoader
- python - Error: RuntimeError: file
line 1: Unable to create/find dependency node