Bird
0
0

You want to reuse an App Action that logs in a user and then navigates to the dashboard. How can you compose these actions correctly?

hard📝 Application Q9 of 15
Cypress - Test Organization and Patterns
You want to reuse an App Action that logs in a user and then navigates to the dashboard. How can you compose these actions correctly?
Aconst loginAndGo = () => { login(); cy.get('#dashboard-link').click(); }
Bconst loginAndGo = (user) => { cy.get('#dashboard-link').click(); login(user); }
Cconst loginAndGo = (user) => { login(user); login(user); cy.get('#dashboard-link').click(); }
Dconst loginAndGo = (user) => { login(user); cy.get('#dashboard-link').click(); }
Step-by-Step Solution
Solution:
  1. Step 1: Understand action composition order

    Login must happen before navigating to dashboard.
  2. Step 2: Check options for correct order and parameters

    const loginAndGo = (user) => { login(user); cy.get('#dashboard-link').click(); } calls login with user, then clicks dashboard link; others have wrong order or missing arguments.
  3. Final Answer:

    Call login(user) first, then click dashboard link -> Option D
  4. Quick Check:

    Compose actions in logical order with correct args [OK]
Quick Trick: Call dependent actions in correct sequence [OK]
Common Mistakes:
  • Clicking dashboard before login
  • Calling login twice unnecessarily
  • Omitting user argument

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes