[英]How to Run & Connect to Emulators with Cypress CI on GitHub Actions?
I am trying to run e2e Cypress tests on Github actions.我正在尝试对 Github 操作运行 e2e Cypress 测试。 I build functions, run an emulator and start cypress like to:
npx nx build functions | firebase emulators:start | nx e2e frontend-e2e --watch
我构建函数,运行模拟器并启动 cypress,例如:
npx nx build functions | firebase emulators:start | nx e2e frontend-e2e --watch
npx nx build functions | firebase emulators:start | nx e2e frontend-e2e --watch
This works well on localhost, but fails on GitHub Actions, when the first part of the code tries to connect to the emulators.这在本地主机上运行良好,但在 GitHub 操作上失败,当代码的第一部分尝试连接到模拟器时。
cy.request(
"DELETE",
"http://localhost:9099/emulator/v1/projects/****/accounts"
);
It can't reach the emulator on port localhost:9099
, as I would normally do on localhost.它无法到达端口
localhost:9099
上的模拟器,就像我通常在 localhost 上做的那样。
1) Login
runs setup:
CypressError: `cy.request()` failed trying to load:
http://localhost:9099/emulator/v1/projects/****/accounts
We attempted to make an http request to this URL but the request failed without a response.
Is there something I need to do about connecting to localhost port on GitHub Actions ?关于连接到 GitHub Actions 上的本地主机端口,我需要做些什么吗?
Solved, The Firebase emulator was throwing an error: but I haven't seen it because I ran it on one line with other commands: npx nx build functions | firebase emulators:start | nx e2e frontend-e2e --watch
已解决,Firebase 模拟器抛出一个错误:但我没有看到它,因为我在一行上与其他命令一起运行它:
npx nx build functions | firebase emulators:start | nx e2e frontend-e2e --watch
npx nx build functions | firebase emulators:start | nx e2e frontend-e2e --watch
I rewrote the job in the workflow:我重写了工作流程中的工作:
- name: Cypress run
uses: cypress-io/github-action@v2
with:
browser: chrome
build: npm run integration:build
start: |
npm run integration:emulate
npm run integration:test
Calling custom scripts from package.json
like so:从
package.json
调用自定义脚本,如下所示:
"integration:build": "nx build functions && nx run frontend:build",
"integration:emulate": "firebase use default && firebase emulators:start",
"integration:test": "nx e2e frontend-e2e --watch",
Then I could see the Firebase error in the log and fixed them.然后我可以在日志中看到 Firebase 错误并修复它们。 There were two issues:
有两个问题:
firebase use default
)firebase use default
) After that, the emulators worked just as on localhost之后,模拟器就像在本地主机上一样工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.