0
0
Cypresstesting~10 mins

Asserting request properties 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 assert the request method is GET.

Cypress
cy.intercept('/api/data').as('getData');
cy.wait('@getData').its('request.method').should('[1]', 'GET');
Drag options to blanks, or click blank then click option'
Aeq
Bequals
Cis
Dequal
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'equals' or 'equal' instead of 'eq' causes assertion failure.
Using 'is' is not a valid Cypress assertion.
2fill in blank
medium

Complete the code to assert the response status code is 200.

Cypress
cy.intercept('/api/data').as('getData');
cy.wait('@getData').its('response.statusCode').should('[1]', 200);
Drag options to blanks, or click blank then click option'
Aequal
Bbe
Cequals
Deq
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'equals' or 'equal' instead of 'eq' causes assertion failure.
Using 'be' alone is not sufficient for equality check.
3fill in blank
hard

Fix the error in the code to assert the request URL includes '/api/data'.

Cypress
cy.intercept('/api/data').as('getData');
cy.wait('@getData').its('request.url').should('[1]', '/api/data');
Drag options to blanks, or click blank then click option'
Acontain
Bincludes
Cinclude
Dcontains
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'contain' or 'contains' causes assertion failure.
Using 'includes' is not a valid Cypress assertion.
4fill in blank
hard

Fill both blanks to assert the request headers contain 'content-type' and its value is 'application/json'.

Cypress
cy.intercept('/api/data').as('getData');
cy.wait('@getData').its('request.headers.[1]').should('[2]', 'application/json');
Drag options to blanks, or click blank then click option'
Acontent-type
Beq
Cequal
DcontentType
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'contentType' instead of 'content-type' causes failure.
Using 'equal' instead of 'eq' causes assertion failure.
5fill in blank
hard

Fill all three blanks to assert the response body has a property 'success' that is true.

Cypress
cy.intercept('/api/data').as('getData');
cy.wait('@getData').its('response.body.[1]').should('[2]', [3]);
Drag options to blanks, or click blank then click option'
Asuccess
Beq
Ctrue
Dbe
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'eq' with 'true' as string causes failure.
Using 'true' without quotes is correct here because it's a boolean.