0
0
Cypresstesting~10 mins

cy.fixture() for loading data 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 fixture file named 'user.json' using Cypress.

Cypress
cy.[1]('user.json').then((data) => {
  expect(data).to.have.property('name')
})
Drag options to blanks, or click blank then click option'
Avisit
Bfixture
Cget
Drequest
Attempts:
3 left
💡 Hint
Common Mistakes
Using cy.visit() instead of cy.fixture() to load data
Trying to use cy.get() to load fixture files
2fill in blank
medium

Complete the code to assert that the loaded fixture data has an 'email' property.

Cypress
cy.fixture('user.json').then((data) => {
  expect(data).to.[1]('email')
})
Drag options to blanks, or click blank then click option'
Acontain
Binclude
Chave.property
Dequal
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'equal' which checks value equality, not property existence
Using 'contain' which is for arrays or strings
3fill in blank
hard

Fix the error in the code to correctly load the fixture and check the username.

Cypress
cy.fixture('user.json').then((data) => {
  expect(data.[1]).to.equal('testuser')
})
Drag options to blanks, or click blank then click option'
Ausername
BuserName
Cuser_name
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect property names like 'userName' or 'name'
Using underscores when the property does not have them
4fill in blank
hard

Fill both blanks to load 'config.json' fixture and assert the 'timeout' value is 5000.

Cypress
cy.[1]('config.json').then((config) => {
  expect(config.[2]).to.equal(5000)
})
Drag options to blanks, or click blank then click option'
Afixture
Btimeout
Cdelay
Drequest
Attempts:
3 left
💡 Hint
Common Mistakes
Using cy.request instead of cy.fixture
Checking wrong property names like 'delay'
5fill in blank
hard

Fill all three blanks to load 'settings.json', check 'theme' is 'dark', and 'version' is '1.2.3'.

Cypress
cy.[1]('settings.json').then((settings) => {
  expect(settings.[2]).to.equal('dark')
  expect(settings.[3]).to.equal('1.2.3')
})
Drag options to blanks, or click blank then click option'
Afixture
Btheme
Cversion
Dconfig
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong command like cy.request
Mixing up property names or misspelling them