作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 Cypress 为这个应用程序编写端到端测试:https://app.gotphoto.com/admin/auth/login
当我从浏览器访问上述 url 时,会显示一个登录表单,正如预期的那样。
当我通过 Cypress 访问上述网址时:
https://app.gotphoto.com/admin/auth/login
https://app.gotphoto.com/__/
并且登录表单未显示 describe('login screen', () => {
it('logs in', () => {
cy.visit('/admin/auth/login');
});
});
使用 cypress.json:
{
"baseUrl": "https://app.gotphoto.com"
}
我创建了一个
repo使用上述配置,因此很容易重现。
最佳答案
/__/
https://app.gotphoto.com/__/
的一部分被称为 客户端路由 是 Cypress 的内部配置项。
您可以在 cypress.json
中将其关闭。配置文件
{
...
"clientRoute": "/"
}
这有效地保留了您的原始网址并允许页面正确加载。
cy.visit('https://app.gotphoto.com/admin/auth/login')
cy.get('input#username', { timeout: 10000 }).type('admin') // long timeout
// wait for page to load
cy.get('input#password').type('password')
cy.intercept('POST', 'api.getphoto.io/v4/auth/login/user').as('user')
cy.contains('button', 'Submit').click()
cy.wait('@user').then(interception => {
// incorrect credentials
expect(interception.response.body.detail).to.eq('Login failed!')
})
我不确定更改
clientRoute
是否有任何不良副作用,如果我找到它会发布更多信息。
关于javascript - 柏树中的应用程序重定向,外部没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66613875/
我是一名优秀的程序员,十分优秀!