Mateusz
Mateusz

Reputation: 41

How to configure Cookies with Cypress?

I'm trying to configure Cypress to have a Cookie in each request header. How do I achieve this? I'm trying this way:

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

Upvotes: 1

Views: 495

Answers (1)

Manuel Abascal
Manuel Abascal

Reputation: 6312

You can use the cy.setCookie() method.

Usage ✅:

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

Upvotes: 1

Related Questions