【发布时间】:2022-01-20 16:23:01
【问题描述】:
我使用开箱即用的 Angular 测试框架:Jasmine 和 karma 用于单元测试和 GCP Cloud Build 来部署应用程序。但是,由于节点 Docker 镜像没有安装 Chrome,所以在测试中出现了问题。
处理这个问题的最佳方法是什么?创建自定义 docker 镜像?或者是否有任何知名的 docker 镜像可供我在 Cloud Build 中构建和测试 Angular 应用程序?
cloudbuild.yaml
steps:
# Install
- name: node:14
entrypoint: npm
args: ["install"]
#Build
- name: node:14
entrypoint: npm
args: ["run", "build", "--", "--aot"]
# Test <- This step fails. See the error message below
- name: node:14
entrypoint: npm
args: ["run", "test", "--", "--watch=false"]
# Deploy to Firebase
- name: gcr.io/$PROJECT_ID/firebase
args: ["deploy", "--project=$PROJECT_ID", "--only=hosting"]
错误
Already have image: node:14
> carealth@0.0.0 test /workspace
> ng test "--watch=false"
- Generating browser application bundles (phase: setup)...
18 01 2022 19:22:45.740:INFO [karma-server]: Karma v6.3.11 server started at http://localhost:9876/
18 01 2022 19:22:45.744:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
18 01 2022 19:22:45.749:INFO [launcher]: Starting browser Chrome
18 01 2022 19:22:45.756:ERROR [launcher]: No binary for Chrome browser on your platform.
Please, set "CHROME_BIN" env variable.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! carealth@0.0.0 test: `ng test "--watch=false"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the carealth@0.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /builder/home/.npm/_logs/2022-01-18T19_22_45_880Z-debug.log
【问题讨论】:
标签: angular docker unit-testing google-cloud-build