Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cypress environment variable undefined

In cypress.json file i have the following code

{
  "baseUrl": "test",
  "ignoreTestFiles": [],
  "viewportHeight": 768,
  "viewportWidth": 1024,
  "video": false,

  "env": { "email": "[email protected]", "password": "password" }
}

When i am trying to access it by calling Cypress.env('password') it shows undefined in console log when printing it, what is the issues.

const password: string = Cypress.env('password')

describe("Login to the application", () => {
  beforeEach(() => {
    cy.visit("/");
  });

  it.only("user should login successfully", () => {
    console.log(Cypress.env('email')).   --- undefined 
    loginPage.login(email, password);
    cy.url().should("include", "/wallet");
  });
like image 538
Artjom Prozorov Avatar asked Jul 02 '26 12:07

Artjom Prozorov


1 Answers

My mistake for not knowing or not checking the location of my cypress.json file, moved it to the top cypress folder and value is shown properly.

like image 138
Artjom Prozorov Avatar answered Jul 04 '26 00:07

Artjom Prozorov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!