0
0
Cypresstesting~10 mins

Waiting for requests (cy.wait with alias) in Cypress - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to wait for the aliased request before continuing the test.

Cypress
cy.intercept('GET', '/api/data').as('getData');
cy.visit('/dashboard');
cy.[1]('@getData');
Drag options to blanks, or click blank then click option'
Aget
Bclick
Cwait
Dvisit
Attempts:
3 left
💡 Hint
Common Mistakes
Using cy.get or cy.click instead of cy.wait to wait for the request.
Not using the alias string with '@' prefix.
2fill in blank
medium

Complete the code to alias a POST request to '/api/login' for later waiting.

Cypress
cy.intercept('POST', [1]).as('loginRequest');
Drag options to blanks, or click blank then click option'
A'/api/data'
B'/api/login'
C'/api/logout'
D'/api/user'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong URL path for the alias.
Forgetting to put the URL in quotes.
3fill in blank
hard

Fix the error in the code to correctly wait for the aliased request.

Cypress
cy.intercept('GET', '/api/items').as('fetchItems');
cy.visit('/items');
cy.wait([1]);
Drag options to blanks, or click blank then click option'
A@fetchItems
B'fetchItems'
CfetchItems
D'@fetchItems'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the alias without '@' prefix.
Not putting the alias in quotes.
Using the alias as a variable instead of a string.
4fill in blank
hard

Fill both blanks to alias a PUT request and wait for it after clicking a button.

Cypress
cy.intercept({ method: [1], url: '/api/update' }).as('updateRequest');
cy.get('button#save').click();
cy.wait([2]);
Drag options to blanks, or click blank then click option'
A'PUT'
B'POST'
C'@updateRequest'
D'@saveRequest'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong HTTP method like POST instead of PUT.
Waiting for the wrong alias string.
5fill in blank
hard

Fill all three blanks to intercept a DELETE request, alias it, and wait after triggering the delete.

Cypress
cy.intercept({ method: [1], url: [2] }).as([3]);
cy.get('button.delete').click();
cy.wait('@deleteRequest');
Drag options to blanks, or click blank then click option'
A'DELETE'
B'/api/delete-item'
C'deleteRequest'
D'/api/remove-item'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong HTTP method like POST or GET.
Using the wrong URL path.
Using an alias name that does not match the wait command.