Overview - Programmatic login (cy.request)
What is it?
Programmatic login using cy.request in Cypress means logging into a web application by sending a direct HTTP request instead of interacting with the login page manually. This method bypasses the user interface and directly authenticates the user by calling the backend login API. It is faster and more reliable because it avoids UI delays and flakiness. This technique helps tests start with an authenticated session quickly.
Why it matters
Without programmatic login, tests must go through the login page every time, which slows down test runs and can cause failures due to UI changes or slow loading. Programmatic login solves this by making tests faster and more stable, allowing developers to focus on testing real features instead of wasting time on repetitive login steps. It also reduces test maintenance and improves confidence in test results.
Where it fits
Before learning programmatic login, you should understand basic Cypress commands, HTTP requests, and how authentication works in web apps. After mastering this, you can explore advanced session management, token handling, and custom commands to reuse login logic efficiently.