I want to define global variables for my tests of the selected application. I want to input them into one file - after reading the documentation I decided to use cypress.env.json.
https://docs.cypress.io/guides/guides/environment-variables.html#Option-1-cypress-json
As I see variables are imported correctly, but during the test, I get the error:
"TypeError: Cannot read property 'env' of undefined"
Any suggestions on how to fix that problem?
https://i.imgur.com/uEVg24I.png
Test file:
describe('/register', () => {
beforeEach(() => {
cy.visit('/#/register')
})
it.only('requires username', () => {
cy.get('input[type="email"]').Cypress.env('correctEmail')
cy.get('input[type="password"]').Cypress.env('correctPassword')
cy.get('button').contains('Sign in').click()
cy.get('.error-messages').should('contain', 'username can\'t be blankis too short (minimum is 1 character)')
})
cypress.env.json:
{
"correctName": "Bob Ross",
"incorrectName": "Bobbbbb",
"correctEmail": "bob@ross.eu",
"incorrectEmail": "b@bbb",
"correctPassword": "bobrosss",
"incorrectPassword": "Oooooo"
}