英文:
Cypress test running locally but skipping tests on github actions
问题
我正在使用GitHub Actions来运行我的测试用例,前两三个月一直正常工作,但现在在GitHub Actions上跳过了测试。尝试添加等待时间,但仍然没有变化。有人可以指导吗?
我增加了超时时间,但在GitHub Actions上仍然跳过了测试,并显示以下错误消息:
断言错误:在10000毫秒后重试超时:预期'/login'与//dashboard$/匹配。
英文:
I am using github actions to run my test cases it is working fine for 2-3 months but now it is skipping test on github actions. Tried adding wait but still nothing change. Can anyone Guide?
I increase timeout but still skipping tests on github actions and giving this error
AssertionError: Timed out retrying after 10000ms: expected '/login' to match //dashboard$/
答案1
得分: 4
第一件要注意的事情是 expected '/login' to match //dashboard$/
是登录失败的一个强烈迹象。
这可能意味着:
- 服务器未运行
- 从 Github 无法访问服务器
- 凭据已过期
所有这些都符合你描述的时间线,测试运行了3个月突然停止。
我建议你在一个新的存储库中添加一个简单的仅登录测试,并检查上述问题的结果。
另一件要检查的事情是 testIsolation
,参见《将测试隔离作为最佳实践》。这是最近引入的,其效果是阻止凭据从一个测试传递到另一个测试。
你可以采取两个步骤:
- 在配置文件中暂时关闭
testIsolation
const { defineConfig } = require('cypress') module.exports = defineConfig({ e2e: { testIsolation: false, }, })
- 在你的登录周围添加
cy.session()
命令,以使登录凭据在多个测试之间保持持久化Cypress.Commands.add('loginWithUI', (username, password) => { cy.session(username, () => { cy.visit('/login') cy.get('#username-input').type(username) cy.get('#password-input').type(password) cy.get('#submit-button').click() }) })
英文:
The first thing to note is that expected '/login' to match //dashboard$/
is a strong indication that the login failed.
This can mean
- the sever isn't running
- the server isn't accessible from Github
- the credentials have expired
All these fit with the chronology you describe, the tests ran for 3 months and suddenly stop.
I suggest you add a simple login-only test in a new repo and check the results for the above problems.
The other thing to check is testIsolation
, see Test Isolation as a Best Practice. This has been recently introduced, and the effect is to block credentials from carrying over from one test to another.
There are two steps you can take:
- temporarily turn off testIsolation in the config file
const { defineConfig } = require('cypress') module.exports = defineConfig({ e2e: { testIsolation: false, }, })
- add a
cy.session()
command around your login to make the login credentials persist across multiple testCypress.Commands.add('loginWithUI', (username, password) => { cy.session(username, () => { cy.visit('/login') cy.get('#username-input').type(username) cy.get('#password-input').type(password) cy.get('#submit-button').click() }) })
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论