0
0
Cypresstesting~10 mins

expect() for BDD assertions 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 check if the value is equal to 10 using expect().

Cypress
expect(value).to.be.[1](10);
Drag options to blanks, or click blank then click option'
Aeq
Bequals
Cequal
Dis
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'equals' instead of 'equal' causes syntax errors.
Using 'eq' is not valid in this context.
2fill in blank
medium

Complete the code to assert that the string includes the word 'hello'.

Cypress
expect(greeting).to.[1]('hello');
Drag options to blanks, or click blank then click option'
Acontain
Binclude
Chas
Dincludes
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'contain' instead of 'include' causes assertion failure.
Using 'includes' is not a valid Cypress assertion method.
3fill in blank
hard

Fix the error in the assertion to check if the array length is 5.

Cypress
expect(array).to.have.length[1](5);
Drag options to blanks, or click blank then click option'
AOf
BOf()
D( )
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting parentheses causes syntax errors.
Using capitalized 'Of' is incorrect.
4fill in blank
hard

Fill both blanks to assert that the variable is a string and equals 'test'.

Cypress
expect(variable).to.be.a([1]).and.[2]('test');
Drag options to blanks, or click blank then click option'
A'string'
Bequal
Cequals
D'str'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'equals' instead of 'equal' causes errors.
Using 'str' instead of 'string' for type check is invalid.
5fill in blank
hard

Fill all three blanks to assert that the object has a property 'name' with value 'Alice' and is not null.

Cypress
expect(obj).to.have.property([1], [2]).and.to.not.be.[3];
Drag options to blanks, or click blank then click option'
A'name'
B'Alice'
Cnull
Dundefined
Attempts:
3 left
💡 Hint
Common Mistakes
Using undefined instead of null for the last blank.
Omitting quotes around property name or value.