I am storing user mocked user creds in a fixture file, and i want to access that data in a before statement, so that each test in that file can have access to a username and password variable. I Know that I can pull in the fixture file and then pull out the creds each time, like this:
describe('Login', () => {
before(() => {
cy.fixture('users').as('users')
})
beforeEach(() => {
cy.visit(LOGIN_PAGE)
})
it.only('can enter an email address', function () {
cy.get(EMAIL_INPUT)
.type(this.users.superUser.username)
cy.get(EMAIL_INPUT).should('have.value', this.users.superUser.username)
})
but instead of having to pull out the this.users.superUser.username
each time and assigning it to a variable, I want to be able to do something like const { username } = this.users.superUser
in the before statement and then have access to that variable. How do I store a variable from a fixture file that i can then access in all my tests in the page without having to pull out the var in each test?