![](/img/trans.png)
[英]Cypress tests are green locally, but failing in CI - tips on debugging?
[英]Cypress tests are green locally, but failing in Gitlab CI
我用 Cypress 實現了 e2e 測試。 它們工作正常,我可以根據應用程序的打包版本使用命令行運行它們: npm run ci:cy-run
。
以下是package.json
中的命令:
"ci:start-server": "angular-http-server --path ./dist/treo -p 4200",
"cy:run": "cypress run --project e2e --browser chrome --headless",
"ci:cy-run": "start-server-and-test ci:start-server http://localhost:4200 cy:run"
當我嘗試使用此 .gitlab-ci.yml 文件在 Gitlab CI 中執行此命令時:
image: teracy/angular-cli:latest
image: cypress/browsers:node12.16.2-chrome81-ff75
build:
stage: build
cache:
paths:
- node_modules/
script:
- npm install --quiet
- npm run build:prod
artifacts:
paths:
- dist/myapp
test:
stage: test
cache:
policy: pull
paths:
- node_modules/
script:
- npm run lint
- npx cypress install
- npm run ci:cy-run
我遇到了一些錯誤,例如:
CypressError: Timed out retrying: `cy.type()` failed because this element is not visible:
`<input formcontrolname="verificationCode" name="verificationCode" matinput="" placeholder="Code à 6 chiffres" required="" type="string" minlength="6" maxlength="6" class="mat-input-element mat-form-field-autofill-control ng-tns-c27-2 ng-untouched ng-pristine ng-invalid cdk-text-field-autofill-monitored" id="mat-input-0" aria-invalid="false" aria-required="true">`
This element `<input#mat-input-0.mat-input-element.mat-form-field-autofill-control.ng-tns-c27-2.ng-untouched.ng-pristine.ng-invalid.cdk-text-field-autofill-monitored>` is not visible because its parent `<div.mat-form-field-infix.ng-tns-c27-2>` has CSS property: `visibility: hidden`
Fix this problem, or use `{force: true}` to disable error checking.
https://on.cypress.io/element-cannot-be-interacted-with
Gitlab 是否有一些特定的配置? 由於無法從 CI 獲取生成的文件(圖像、視頻),如何調試此問題?
非常感謝您的幫助! 蒂埃里
您可以使用工件從 gitlab CI 中的 Cypress 獲取視頻/屏幕截圖,只需確保將它們放在應用程序的文件夾結構中。
我現在正在處理的示例生成一個可下載的屏幕截圖文件夾:
e2e tests all:
image: cypress/base:14.15.4
stage: manual-tests
when: manual
allow_failure: true
before_script:
- npm install
- npx cypress verify
script:
- npm run-script test:e2e
cache:
<<: *global_cache
policy: pull
artifacts:
paths:
- tests/e2e/screenshots/**/*.png
expire_in: 2 hrs
when: on_failure
這將在我們的 VueJS 應用程序中獲取屏幕截圖文件夾。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.