cypress - 设置 github 操作以从 2 个不同的存储库在 localhost 上运行 cypress 测试
问题描述
我的前端 (repUI) 和 cypress 测试 (repTest) 在单独的存储库中。我正在尝试通过从 repTest 签出来运行测试。一旦设置了 repUI(安装和构建),localhost:8000
就可以运行测试了。
到目前为止,设计了以下工作流程:
name: Cypress E2E Tests on Dev
on:
workflow_dispatch:
push:
branches-ignore: [ main ]
schedule:
- cron: '0 0 * * 1-5'
jobs:
setup:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [14.x]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
# Checkout UI repo
- name: Checkout voy-frontend repo
uses: actions/checkout@v2
with:
repository: orgName/xyz-frontend
path: xyz-frontend
ssh-key: ${{ secrets.GIT_SSH_KEY }}
# Install voy-f dependancies
- name: Install dependancies for application
run: |
cd voy-frontend
pwd
npm install
- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
# Run application
- name: Run application
run: |
pwd
cd voy-frontend
npm run serve
cypress-test:
name: Test
needs: setup
runs-on: ubuntu-latest
steps:
# Checkout test automation repo
- name: git checkout
uses: actions/checkout@v2
with:
ref: main
# Install cypress dependancies
- name: Cypress install
uses: cypress-io/github-action@v2
# Run cypress tests
- name: Cypress run - localhost
run: npm run cy:r -- --env TENANT=${{ secrets.TENANT }},CLIENT_ID=${{ secrets.CLIENT_ID }},CLIENT_SECRET=${{ secrets.CLIENT_SECRET }},ORG_SCOPE=${{ secrets.ORG_SCOPE }},G_SCOPE=${{ secrets.G_SCOPE }} --spec "cypress/integration/specs/Search.feature" --headless --browser chrome
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-videos
path: |
cypress/reports
cypress/videos
cypress/screenshots
retention-days: 1
问题是,如果我为 repUI 运行构建命令npm run serve
,应用程序成功启动,但它没有继续进行,而是等待。如果我注释掉 ,则npm run serve
所有其他作业都按应有的方式运行。
对于构建,它只花了大约 60 秒,然后等到我取消它。如果我总是再次触发工作,情况也是如此。
cypress-test
一旦构建准备好,需要做什么才能继续工作。?
解决方案
推荐阅读
- flask - 从 QuerySelectField 中删除重复项
- postgresql - 如何正确设置多边形 PostGis 的点?
- nativescript - 如何使用 RadListView 分组功能捕捉点击类别标题?(本机脚本)
- sql - Dapper 查询,结合属性与分页一起使用
- node.js - 如何在 MochaJS 的钩子之前运行异步函数?
- java - 如何使用邮递员发布请求在标头中传递对象?
- regex - 如何使用 Regex 替换 OnChanging 事件中的字符并将插入符号保留在 ExtendScript 中 EditText 的末尾?
- reactjs - 当我点击地图的某个部分时,如何在 react-google-maps 上放置动态标记?
- android - 如何在移动应用程序中限制 Google Map API 密钥?
- python - 使用特定方法对字符串列表进行排序