0
0
Cypresstesting~10 mins

Why test structure organizes assertions 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 start a Cypress test with a descriptive block.

Cypress
describe('[1]', () => {
  it('checks page title', () => {
    cy.visit('https://example.com')
    cy.title().should('include', 'Example')
  })
})
Drag options to blanks, or click blank then click option'
Acontext
Bdescribe
Cit
DTest Suite
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'it' instead of a descriptive name for the test group.
Leaving the describe block name empty.
2fill in blank
medium

Complete the code to write a single test case inside the describe block.

Cypress
describe('Homepage tests', () => {
  [1]('should load the homepage', () => {
    cy.visit('/')
    cy.get('h1').should('be.visible')
  })
})
Drag options to blanks, or click blank then click option'
Ait
Bcontext
Cdescribe
Dtest
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'describe' inside another describe for test cases.
Using 'context' instead of 'it' for test cases.
3fill in blank
hard

Fix the error in the assertion to check if the button is enabled.

Cypress
it('checks submit button', () => {
  cy.get('button.submit').should([1])
})
Drag options to blanks, or click blank then click option'
A'enabled'
B'be.enabled'
C'enableded'
D'be.enableded'
Attempts:
3 left
💡 Hint
Common Mistakes
Misspelling 'enabled' as 'enableded'.
Omitting 'be.' prefix in the assertion.
4fill in blank
hard

Fill both blanks to organize multiple assertions inside a test case.

Cypress
it('checks multiple elements', () => {
  cy.get('input#name').should([1])
  cy.get('input#email').should([2])
})
Drag options to blanks, or click blank then click option'
A'be.visible'
B'exist'
C'be.enabled'
D'contain.text'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'contain.text' when checking for element presence.
Mixing up 'exist' and 'be.visible' assertions.
5fill in blank
hard

Fill all three blanks to write a test that checks text content and button state.

Cypress
it('validates form elements', () => {
  cy.get('label[for="username"]').should([1], 'username')
  cy.get('input#username').should([2])
  cy.get('button.submit').should([3])
})
Drag options to blanks, or click blank then click option'
A'contain.text'
B'exist'
C'be.enabled'
D'be.visible'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'be.visible' for label text check instead of 'contain.text'.
Checking button with 'exist' instead of 'be.enabled'.