gpt4 book ai didi

javascript - 柏树中的应用程序重定向,外部没有

转载 作者:行者123 更新时间:2023-12-03 21:06:09 25 4
gpt4 key购买 nike

我正在尝试使用 Cypress 为这个应用程序编写端到端测试:https://app.gotphoto.com/admin/auth/login当我从浏览器访问上述 url 时,会显示一个登录表单,正如预期的那样。
当我通过 Cypress 访问上述网址时:

  • cypress 首先导航到 https://app.gotphoto.com/admin/auth/login
  • 紧接着我被重定向到 https://app.gotphoto.com/__/并且登录表单未显示

  • 这是 Cypress 内部的两个屏幕截图:
    enter image description here
    enter image description here
    我的问题是:为什么它在我的浏览器中的运行方式与它在 Cypress / Cypress 的浏览器中的运行方式之间存在差异?
    我使用的浏览器是 Chrome 89,无论在有和没有 Cypress 的情况下运行。
    我正在运行的整个测试是这样的:
    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/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com