0
0
Cypresstesting~10 mins

Why assertions verify expected behavior in Cypress - Test Your Understanding

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

Complete the code to check if the page contains the text 'Welcome'.

Cypress
cy.contains([1])
Drag options to blanks, or click blank then click option'
A'Welcome'
BWelcome
C"welcome"
Dwelcome
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put quotes around the text string.
Using incorrect case in the string.
2fill in blank
medium

Complete the assertion to verify the button is visible.

Cypress
cy.get('button').should([1], true)
Drag options to blanks, or click blank then click option'
A'visible'
B'exist'
C'be.visible'
D'show'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'exist' instead of 'be.visible' which only checks presence, not visibility.
Omitting quotes around the assertion string.
3fill in blank
hard

Fix the error in the assertion to check the input has value 'test'.

Cypress
cy.get('input').should('have.value', [1])
Drag options to blanks, or click blank then click option'
A`test`
Btest
C"test"
D'test'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the string value.
Using backticks which are less common here.
4fill in blank
hard

Fill both blanks to assert the checkbox is checked and enabled.

Cypress
cy.get('input[type=checkbox]').should([1]).and([2])
Drag options to blanks, or click blank then click option'
A'be.checked'
B'be.enabled'
C'checked'
D'enabled'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'checked' without 'be.' prefix.
Using 'enabled' without 'be.' prefix.
5fill in blank
hard

Fill all three blanks to assert the list has 5 items, the first item contains 'Item 1', and the list is visible.

Cypress
cy.get('ul > li').should([1], 5).first().should([2], [3]).parent().should('be.visible')
Drag options to blanks, or click blank then click option'
A'have.length'
B'contain.text'
C'Item 1'
D'have.text'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'have.text' instead of 'contain.text' which requires exact match.
Not chaining assertions properly.