lecture 5 of 160 completed

cy.session at scale

Login is usually the largest single cost in a suite. cy.session removes most of it, and its cache rules decide whether that works.

What you'll learn

  • How to key a cached session so tests cannot run as the wrong user
  • Why validation is what makes caching safe
  • How to handle several roles without collisions

Four hundred tests. Each logs in through the form. Each login takes three seconds. That is twenty minutes of every run spent typing the same password, and it is usually the single largest line item in a suite's runtime.

You met cy.session in the intermediate track. This lecture is about the parts that matter when you have hundreds of tests and several user types, because that is where the caching rules stop being a detail.

The mental model. cy.session runs your login once, then saves the resulting cookies, localStorage and sessionStorage under a key you choose. Next time that key appears, it restores the saved state instead of running the login again.

members only

Keep reading with the full course

The Foundations track and the first 5 lectures of each framework are free. This lecture is part of the paid course, which unlocks every lecture, all three frameworks, and downloads.

See the options →