【问题标题】:How to configure Cookies with Cypress?如何使用 Cypress 配置 Cookie?
【发布时间】:2021-04-17 17:46:38
【问题描述】:

我正在尝试将Cypress 配置为在每个请求header 中有一个Cookie。我如何实现这一目标?我正在尝试这种方式:

it('successfully loads', () => {
    cy.visit('http://localhost:4200', { headers: { Cookie: 'JSESSIONID=064063D96094773DACBD93A2FD31736F' } });
});

【问题讨论】:

    标签: javascript testing cookies cypress e2e-testing


    【解决方案1】:

    您可以使用cy.setCookie() 方法。

    用法✅:

    cy.setCookie('auth_key', '123key') // Set the 'auth_key' cookie to '123key'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-16
      • 2020-01-10
      • 2019-09-08
      • 1970-01-01
      • 1970-01-01
      • 2019-06-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多