0
0
Cypresstesting~10 mins

Automatic retry mechanism 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 retry the assertion automatically in Cypress.

Cypress
cy.get('button').click();
cy.get('.result').should([1], 'Success');
Drag options to blanks, or click blank then click option'
A'have.text'
B'be.visible'
C'contain'
D'exist'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'contain' instead of 'have.text' which allows partial match.
Using 'exist' which only checks presence, not text content.
2fill in blank
medium

Complete the code to retry a custom command until it succeeds.

Cypress
Cypress.Commands.add('checkStatus', () => {
  cy.request('/status').its('body.status').should([1], 'ready');
});
Drag options to blanks, or click blank then click option'
A'match'
B'contain'
C'equal'
D'include'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'include' or 'contain' which check partial matches and may not be precise.
Using 'match' which is for regex and not suitable here.
3fill in blank
hard

Fix the error in the retry assertion to correctly wait for the element to be visible.

Cypress
cy.get('.loading').should([1]);
Drag options to blanks, or click blank then click option'
A'show'
B'visible'
C'is.visible'
D'be.visible'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'visible' without 'be.' prefix causes syntax error.
Using 'is.visible' or 'show' which are invalid assertions.
4fill in blank
hard

Fill both blanks to retry the assertion that the input value is 'test'.

Cypress
cy.get('input').should([1], [2]);
Drag options to blanks, or click blank then click option'
A'have.value'
B'value'
C'test'
D'input'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'value' instead of 'have.value' for the assertion name.
Using 'input' instead of the expected value string.
5fill in blank
hard

Fill all three blanks to retry a custom command that waits for a status 'complete' and asserts it.

Cypress
Cypress.Commands.add('waitForComplete', () => {
  cy.request('/task-status').its([1]).should([2], [3]);
});
Drag options to blanks, or click blank then click option'
A'body.status'
B'equal'
C'complete'
D'status'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'status' instead of 'body.status' which does not access the nested property.
Using 'include' or 'contain' instead of 'equal' for exact match.