red*_* 87 20 javascript node.js cypress
问题
我正在为 Cypress 运行集成测试,该测试在本地运行良好,但在 Gitlab 中运行时失败。我收到的错误是在使用cy.visit()导致以下错误的命令时发生的:
CypressError: `cy.visit()` failed trying to load:
http://localhost:3000/ The response we received from your web server
was:
404: Not Found
Run Code Online (Sandbox Code Playgroud)
配置
我使用以下命令启动测试:
tests:
image: cypress/base:10
stage: tests
script:
- npm ci
- npm run test:ci
Run Code Online (Sandbox Code Playgroud)
这些命令在我的中看起来像这样package.json:
"scripts": {
"start:ci": "serve dist --no-clipboard --listen ${PORT:-3000}",
"test": "cross-env NODE_ENV=test && npm run test:jest && npm
run test:cypress",
"test:ci": "start-server-and-test start:ci http://localhost:3000 test",
"test:cypress": "cypress run --headless",
"test:jest": "jest",
},
Run Code Online (Sandbox Code Playgroud)
研究
我调查了这个错误,发现这个线程帮助我稍微理解了这个问题。然后我尝试将以下配置添加到我的cypress.json文件中:
{
"baseUrl": "http://localhost:3000"
}
Run Code Online (Sandbox Code Playgroud)
但我仍然遇到同样的错误。为什么会这样呢?
| 归档时间: |
|
| 查看次数: |
30897 次 |
| 最近记录: |