Bird
0
0

For a large Cypress test suite with 100 tests requiring login, which strategy best optimizes speed and reliability using login caching?

hard📝 Application Q8 of 15
Cypress - Authentication and Sessions
For a large Cypress test suite with 100 tests requiring login, which strategy best optimizes speed and reliability using login caching?
AAvoid caching and clear cookies after every test to prevent session reuse.
BPerform login manually in each test without caching to ensure fresh sessions.
CCache login in each test's <code>beforeEach()</code> hook to isolate sessions per test.
DUse <code>cy.session()</code> once in a global <code>before()</code> hook to cache login for all tests.
Step-by-Step Solution
Solution:
  1. Step 1: Consider test suite size

    With 100 tests, repeated login slows down execution significantly.
  2. Step 2: Best caching practice

    Using cy.session() once in a global before() hook caches login once for all tests.
  3. Step 3: Avoid redundant logins

    Logging in each test or clearing cookies wastes time and reduces reliability.
  4. Final Answer:

    Use cy.session() once in a global before() hook to cache login for all tests. -> Option D
  5. Quick Check:

    Global session caching maximizes speed and stability [OK]
Quick Trick: Cache login once globally for large test suites [OK]
Common Mistakes:
  • Logging in every test without caching
  • Caching login in each test separately
  • Clearing cookies unnecessarily after tests

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes