Cypress在本地运行得很好。当我尝试在circle-ci管道中运行它时,它有很多问题。首先,这是我的工作流程的相关部分:
orbs:
cypress: cypress-io/cypress@1.19.2
workflows:
version: 2.1
commit:
jobs:
- cypress/install:
install-command: 'npm install --no-optional --unsafe-perm'
- cypress/run:
requires:
- cypress/install
start: 'lerna run start --parallel'
当我查看circle-ci中的操作时,它成功编译,但立即取消
project/applicable-folder: ℹ 「wdm」: Compiled successfully.
Build was canceled
在构建过程中,我注意到这一行
project/applicable-folder: Failed to load /root/project/.env.
.env绝对就在那里。
npx cypress run
会在此之后运行,但所有测试都会失败,因为即使是cy.visit('/');
的测试也会失败。
为什么无法成功访问env文件?我是不是错过了一个允许它运行的步骤?我甚至应该允许它运行吗?我不确定如何继续。
我也尝试过使用build而不是start,但这并不能更好地工作。
我还使用了一种手动策略:
测试:e2e: docker:-镜像:docker-镜像步骤:- checkout - restore_cache:密钥:- v2-deps-{{ .Branch }}-{{ checksum "package-lock.json“}}- v2-deps-{{ .Branch }} -- v2-deps- - run: npm ci- save_cache:密钥: v2-deps-{{ .Branch }}-{{ checksum "package-lock.json“}}路径:- ~/.npm - ~/.cache - run:名称:运行用户验收测试命令: npm Run cy:run
这将导致需要安装Xvfb。
这是否意味着只要安装了它,它就应该可以工作?我宁愿使用orb版本。
编辑:我试用了库start-server-and-test
。
脚本如下所示
"cy:pipeline": "start-server-and-test up http-get://localhost:8080 cy:run"
"cy:run": "cypress run --headless --record"
"up": "lerna run start --parallel"
新柏树/奔跑
- cypress/run:
requires:
- cypress/install
record: true
command: 'npm run cy:pipeline'
但我也收到了同样的错误,
发布于 2020-04-26 00:36:34
解决方案很简单。
我所要做的就是将安装命令从cypress/install
移到cypress/run
。
- cypress/install
- cypress/run:
requires:
- cypress/install
start: 'lerna run start --parallel'
install-command: 'npm install --no-optional --unsafe-perm'
发布于 2020-04-22 21:34:01
尝试从官方circleci频道观看this关于柏树集成的精彩演示,这将有助于解决您的问题
发布于 2020-04-23 00:18:18
我觉得webpack开发的服务器马上就要退出了,这是不是react-scripts
?
https://stackoverflow.com/questions/61354827
复制相似问题