0
0
Cypresstesting~10 mins

JSON fixture files 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 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'
A'user.json'
B'user'
C'data'
D'data.json'
Attempts:
3 left
💡 Hint
Common Mistakes
Including the '.json' extension in the fixture name.
Using a wrong file name.
2fill in blank
medium

Complete 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'
Aproperty
BhaveOwnProperty
Ccontain
Dinclude
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'include' or 'contain' which check values, not properties.
Using JavaScript's 'hasOwnProperty' method instead of Chai assertion.
3fill in blank
hard

Fix 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'
A"john_doe"
Bjohn_doe
C'john_doe'
Ddata.username
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the expected string value.
Using the variable name instead of the string.
4fill in blank
hard

Fill 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'
Afixture
Brequest
Cintercept
Dsettings
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'request' or 'intercept' which are for network calls, not fixtures.
Including '.json' in the fixture name.
5fill in blank
hard

Fill 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'
Afixture
Bprofile
Cabove
Dequal
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'.