我在运行测试时遇到了奇怪的行为Cypress。似乎cy.visit()无法通过请求发送 cookie。
首先,是的,cypress/supports/index.js我已经设置了:
Cypress.Cookies.defaults({
preserve: 'token'
})
Run Code Online (Sandbox Code Playgroud)
在我的测试中,我执行以下操作:
it('test', () => {
cy.logIn()
cy.getCookie('token').then(console.log)
cy.visit('/')
// verify that the user is redirected to /home, which it isn't...
})
Run Code Online (Sandbox Code Playgroud)
为了让用户登录,我运行自定义logIn()命令,该命令成功地使用户登录。执行此操作后,应用程序会设置一个token以会话令牌命名的 cookie。然后我console.log在调用之前成功获取了 cookie cy.visit()。但是,我的后端收到没有 cookie 的请求,因此没有按预期执行重定向...
有人遇到过类似的事情吗?有什么想法可能会发生什么吗?
| 归档时间: |
|
| 查看次数: |
3155 次 |
| 最近记录: |