Complete the code to load a fixture file named 'user.json' in a Cypress test.
cy.fixture('[1]').then((user) => { expect(user).to.have.property('name') })
The cy.fixture() command loads the fixture file by its filename including extension. Here, 'user.json' is the correct file name.
Complete the code to use the loaded fixture data inside a test.
cy.fixture('user.json').then(([1]) => { cy.log([1].email) })
The parameter name in the then callback can be any valid variable name. Here, 'user' is used to represent the loaded fixture data.
Fix the error in the code to correctly use fixture data in a test.
beforeEach(() => {
cy.fixture('settings.json').[1]((settings) => {
this.settings = settings
})
})The cy.fixture() command returns a chainable. To access the loaded data, use then to handle the promise.
Fill both blanks to correctly assert a property from fixture data in a test.
cy.fixture('profile.json').then((data) => { expect(data.[1]).to.[2]('active') })
The fixture data property to check is 'status'. The assertion method to check equality is 'equal'.
Fill all three blanks to create a test that loads a fixture, visits a URL, and asserts a page element contains fixture data.
cy.fixture('[1]').then((user) => { cy.visit('[2]') cy.get('[3]').should('contain', user.name) })
The fixture file is 'user.json'. The test visits the '/profile' page. The selector '.profile-name' targets the element showing the user's name.