Cypress - Authentication and Sessions
You want to programmatically log in and then visit a protected page. Which code snippet correctly ensures the login completes before visiting the page?
cy.request returns a promise; visiting protected page must wait for login.
cy.request({ method: 'POST', url: '/login', body: { username: 'user', password: 'pass' } }).then(() => { cy.visit('/dashboard'); }); uses then() to visit after login completes.
15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions