方式一、在header中增加一个Cookie
it('successfully loads', () => {
cy.visit('http://localhost:4200', { headers: { Cookie: 'JSESSIONID=064063D96094773DACBD93A2FD31736F' } });
});
方式二、使用cy.setCookie()
cy.setCookie('auth_key', '123key') // Set the 'auth_key' cookie to '123key'
相关操作:
cy.getCookie()
cy.getCookies()
cy.setCookie()
cy.clearCookie()
cy.clearCookies()
其他相关设置Cookie:https://blog.csdn.net/qq_33801641/article/details/110107250