Cypressを使ってE2Eテストを実施することにしたが、これをCloud Buildで実施したい
考えているフロー
Cypressのdocker imageをCloud Buildで利用する
そして、Cloud BuildでCypressを実行したあと、ScreenshotをGCSに登録する
ローカルで試してみる
まずは、ローカルでCloud Buildを実行してみる
cloudbuild.yaml
--- steps: - name: "cypress/base" entrypoint: "bash" args: ["-c", "npm install --save-dev cypress"] - name: "cypress/base" entrypoint: "bash" args: ["-c", "$(npm bin)/cypress run"] artifacts: objects: location: 'gs://screenshot' paths: [ 'cypress/screenshots/*.spec.js/*.png', ]
※実行するにはnpm install
が必要であるという以下のメッセージがでたのでnpm install
を行う
: Already have image (with digest): cypress/included:3.4.0 : The cypress npm package is installed, but the Cypress binary is missing. : : We expected the binary to be installed here: /builder/home/.cache/Cypress/3.4.0/Cypress/Cypress : : Reasons it may be missing: : : - You're caching 'node_modules' but are not caching this path: /builder/home/.cache/Cypress : - You ran 'npm install' at an earlier build step but did not persist: /builder/home/.cache/Cypress : : Properly caching the binary will fix this error and avoid downloading and unzipping Cypress. : : Alternatively, you can run 'cypress install' to download the binary again. : : https://on.cypress.io/not-installed-ci-error
うまくいったのでこれをGCP上で実行してみる