Cypress 获取登录态

Cypress.Commands.add('login', (email, password) => {
    Cypress.log({
      name: 'loginAPI',
      message: [`Login with ${email}, ${password}`],
    })
    const envVariable = Cypress.env()
    cy.request({
      method: 'POST',
      url: envVariable.loginUrl,
      body: {
        "env": envVariable.env,
        "email": email,
        "password": password
      }
    }).then((res)=>{
      cy.setCookie('expiryTime', res.body.expiryTime);
      cy.setCookie('token', res.body.token);
    })
  })

你可能感兴趣的:(Cypress 获取登录态)