NodeJS docker 镜像在 gitlab-ci 中运行 Angular 测试

时间:2021-07-28 16:40:34

标签: gitlab-ci docker-image angular-test

当我尝试使用命令运行测试时,我尝试使用 gitlab-ci 和节点 docker 映像构建一个小型 Angular 应用程序 npm run test 它失败并出现以下错误:

ERROR [launcher]: No binary for Chrome browser on your platform. Please, set "CHROME_BIN" env variable.

gitlab-ci.yml

stages:
- build

variables:
  NPM_CONFIG_REGISTRY: https://test.com/xx/api/npm/npm-all

build:
  stage: build
  image: node:12.9
  script:
    - npm install
    - npm run build:prod
    - npm run test
  tags:
    - DOCKER

在上面的代码中npm run test按照package.json中的配置执行ng test

我能够运行构建,但是当我运行测试时,它会寻找 chrome 浏览器,我还尝试使用以下命令以无头方式运行测试,但导致相同的错误:

ng test --no-watch --browsers=ChromeHeadless

如何将 chrome 功能添加到此版本中?

1 个答案:

答案 0 :(得分:0)

自行安装 Chrome 或尝试使用现有的 Docker image that already includes it