如何解决github-actions 如何在生产构建结果而不是开发模式上运行测试
我目前在 Create React App 中有一个这样的 github 操作
name: Percy
on: [push]
jobs:
percy:
name: Visual Testing
runs-on: ubuntu-16.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cypress run
uses: cypress-io/github-action@v2
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
with:
start: yarn start
wait-on: 'http://localhost:3000'
command-prefix: 'percy exec -- npx'
但我想为我的测试(cypress 等)yarn build
(而不是 yarn start
)和 serve
这些结果 - 所以我看看如何测试继续进行webpack
。
我尝试了很多不同的方法(例如 start: yarn build && yarn serve -s build -p 3000
),但得出的结论是我需要一些指导。
...
$ react-scripts build '&&' yarn serve -s build -p 3000
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
49.3 KB build/static/js/2.98954ae7.chunk.js
3.01 KB build/static/js/main.9bc31c1d.chunk.js
1.13 KB build/static/css/main.9e43f7ef.chunk.css
818 B build/static/css/2.a2fbc952.chunk.css
779 B build/static/js/runtime-main.fe4fcbcb.js
The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
You may serve it with a static server:
yarn global add serve
serve -s build
Find out more about deployment here:
bit.ly/CRA-deploy
Done in 10.36s.
http://localhost:3000 timed out on retry 61 of 2
Error: connect ECONNREFUSED 127.0.0.1:3000
解决方法
您可以使用 build
参数使用 yarn build
构建应用程序,使用 start
参数使用 npx serve
启动服务器。
- name: Cypress run
uses: cypress-io/github-action@v2
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
with:
build: yarn build
start: npx serve -s build -l 3000
wait-on: 'http://localhost:3000'
command-prefix: 'percy exec -- npx'
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。