当我在 GitLab CI 环境中运行时,npm run cypress:run出现错误:
您的 configFile 无效://WebApp/cypress.config.ts 在需要时抛出错误,请检查下面的堆栈跟踪: TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for //WebApp/cypress.config.ts
test:cypress:
image:
name: cypress/included:10.3.1-typescript
entrypoint: ['']
stage: test
script:
- yarn install --frozen-lockfile
- cd WebApp
- npm run cypress:run
rules:
- *branch
Run Code Online (Sandbox Code Playgroud)
npm run cypress:run如果我从本地WebApp文件夹(位于根目录中)运行,cypress.config.ts则没有问题。当我做一个时也没有问题npx cypress:run
但是,如果我npx cypress run --config-file WebApp/cypress.config.ts在本地从父文件夹运行,我确实会收到错误:
未知的文件扩展名“.ts”
为什么 Cypress 在本地工作正常,但在 CI 上配置文件不正确,有什么想法吗?
小智 9
我用更多信息更新了这个 github 问题。
这是因为你的机器上全局安装了 typescript,所以它在本地可以正常工作,但在 CI 中却不行。
本质上,打字稿必须位于运行 cypress 命令的文件夹中,才能正确检测打字稿。
我去了:
script:
- npm install --global serve
- serve ./build --listen 3000 &
- rm package*
- npm install @percy/cypress typescript
- npm install --global @percy/cli
- percy exec --verbose -- cypress run
Run Code Online (Sandbox Code Playgroud)
只需安装最低限度的内容即可运行 e2e 测试。/build是另一次运行的产物,如果您以前没有使用过,percy真的很棒。
| 归档时间: |
|
| 查看次数: |
13092 次 |
| 最近记录: |