A. The intercept is missing an alias '@login' for cy.wait.
B. The reply status code 201 is invalid for POST requests.
C. The cy.get selector is incorrect for the submit button.
D. The intercept callback should not use req.reply.
Solution
Step 1: Check intercept alias usage
The intercept does not have an alias set with .as('login'), so cy.wait('@login') will fail.
Step 2: Verify other parts
Status code 201 is valid for POST creation. The selector and req.reply usage are correct.
Final Answer:
The intercept is missing an alias '@login' for cy.wait. -> Option A
Quick Check:
Missing .as('login') causes cy.wait failure [OK]
Hint: Always alias intercept to use cy.wait('@alias') [OK]
Common Mistakes:
Not adding .as() alias to intercept
Confusing valid HTTP status codes
Misunderstanding req.reply usage
5. You want to test how your app handles a slow API response using Cypress intercept. Which approach correctly simulates a 2-second delay on a GET request to '/api/items' and verifies the UI shows a loading spinner during the wait?
hard
A. Use cy.intercept('GET', '/api/items', (req) => { req.on('response', (res) => { res.setDelay(2000); }); }).as('getItems');
Then check spinner visibility before cy.wait('@getItems').
B. Use cy.intercept('GET', '/api/items').as('getItems');
Then use cy.wait(2000) before checking spinner visibility.
C. Use cy.intercept('GET', '/api/items', (req) => { req.delay(2000); }).as('getItems');
Then check spinner visibility after cy.wait('@getItems').
D. Use cy.intercept('GET', '/api/items', { delay: 2000 }).as('getItems');
Then check spinner visibility before cy.wait('@getItems').
Solution
Step 1: Simulate delay correctly in intercept
Using { delay: 2000 } as the static route handler correctly adds a 2-second delay to the response.
Step 2: Verify spinner visibility timing
Check the loading spinner is visible before waiting for the delayed response to finish with cy.wait('@getItems').
Final Answer:
Use cy.intercept('GET', '/api/items', { delay: 2000 }).as('getItems');
Then check spinner visibility before cy.wait('@getItems'). -> Option D
Quick Check:
{ delay: 2000 } simulates slow response [OK]
Hint: Use { delay: 2000 } object in cy.intercept [OK]
Common Mistakes:
Using invalid req.on('response', res => res.setDelay()) syntax
Calling delay method directly on req
Checking spinner only after wait instead of before
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.