Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

350
Views
How to add types to Cypress.env?

I have this cypress.json config file:

{
  "env": {
    "example": "Hello World!"
  }
}

In my tests:

Cypress.env("example")

Can I add any kind of type defintion to the env system? (to work with Typescript or eslint) I would love to use intellisense here.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

From cypress.d.ts

interface Cypress {
  /**
   * Returns specific environment variable or undefined
   * @see https://on.cypress.io/env
   * @example
   *    // cypress.json
   *    { "env": { "foo": "bar" } }
   *    Cypress.env("foo") // => bar
  */
  env(key: string): any
}

so you can extend it with

declare namespace Cypress {
  interface Cypress {
    env(key: "example"): string
  }
}

which gives intellisense (method) Cypress.Cypress.env(key: "example"): string (+6 overloads)

about 4 years ago · Juan Pablo Isaza Report

0

According to documentation:

    Cypress.env("myOwnTypeKey", {
        value: "yourOwnKey",
        type: "myOwnTypeClass"
    });

should set a specific variable with myOwnTypeKey. Then you could check if the "yourOwnKey" with a call to instanceof "myOwnTypeClass".

Value could be a complex object as well.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!