Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load a JSON fixture file named 'user'.
Cypress
cy.fixture('[1]').then((data) => { cy.log(data.name) })
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including the '.json' extension in the fixture name.
Using a wrong file name.
✗ Incorrect
In Cypress, when loading a fixture, you provide the file name without the '.json' extension.
2fill in blank
mediumComplete the code to assert that the loaded fixture has a property 'email'.
Cypress
cy.fixture('user').then((data) => { expect(data).to.have.[1]('email') })
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'include' or 'contain' which check values, not properties.
Using JavaScript's 'hasOwnProperty' method instead of Chai assertion.
✗ Incorrect
The correct Chai assertion to check for a property is 'property'.
3fill in blank
hardFix the error in the code to correctly load the fixture and check the username.
Cypress
cy.fixture('user').then((data) => { expect(data.username).to.equal([1]) })
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the expected string value.
Using the variable name instead of the string.
✗ Incorrect
The expected value must be a string literal, so it needs quotes around it.
4fill in blank
hardFill both blanks to load a fixture named 'settings' and assert the 'theme' is 'dark'.
Cypress
cy.[1]('[2]').then((data) => { expect(data.theme).to.equal('dark') })
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'request' or 'intercept' which are for network calls, not fixtures.
Including '.json' in the fixture name.
✗ Incorrect
Use 'fixture' to load the JSON file named 'settings'.
5fill in blank
hardFill all three blanks to load 'profile' fixture, check 'age' is greater than 18, and log the name.
Cypress
cy.[1]('[2]').then((data) => { expect(data.age).to.be.[3](18) cy.log(data.name) })
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'equal' instead of 'above' for greater than check.
Including '.json' in the fixture name.
Using wrong Cypress command instead of 'fixture'.
✗ Incorrect
Use 'fixture' to load 'profile', and 'above' to assert age > 18.