sincecutoff.com
← all changes

Cypress environment access adds cy.env() and deprecates Cypress.env()

Introduced 2026-02-03 · score 0.97

HOW TO USE IT

When tests read Cypress environment variables, migrate those reads to `cy.env()` and request only the needed keys. After migrating all usages on Cypress 15.10.x, set `allowCypressEnv: false` in the Cypress configuration to prevent further use of `Cypress.env()`.

cy.env(['<key>']).then(({ <key> }) => { // Use <key> here })
const { defineConfig } = require('cypress') module.exports = defineConfig({ allowCypressEnv: false, })

WHY THIS HELPS

Update Cypress tests that access environment variables to use the asynchronous secure API and prevent remaining use of the deprecated API.

BEFORE THIS CHANGE

Use `Cypress.env()` to access Cypress environment variables.

REQUIREMENTS AND LIMITATIONS

  • Version: 15.10.0
  • keys (required): Non-empty array of non-empty environment variable key strings to retrieve. Undefined values are returned for keys not set.
  • options.log: Boolean; defaults to `true`. Displays the command and requested key names in the Command Log, never values.
  • options.timeout: Milliseconds to wait for `cy.env()` to resolve; defaults to `4000` and does not follow `defaultCommandTimeout`.
  • allowCypressEnv: Set to `false` in Cypress configuration to disallow the deprecated `Cypress.env()` API on Cypress ^15.10.0.
  • Prerequisite: `cy.env()` requires Cypress 15.10.0 or newer, must be chained from `cy`, and requires a non-empty array of non-empty strings.
  • Prerequisite: `allowCypressEnv` is available on Cypress ^15.10.0; Cypress 16.0 removes both it and `Cypress.env()`.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card