Cypress v16 changed how environment variables work, making CYPRESS_-prefixed variables private by default and inaccessible outside test blocks. To fill the gap for passing public (non-secret) configuration values to specs, the author created the cypress-expose plugin. It reads any CYPRESS_EXPOSE_... process environment variable and exposes it via Cypress.expose in camel-case form, keeping secrets private via cy.env while making non-sensitive config values accessible anywhere in spec files. Setup requires adding the plugin to the setupNodeEvents callback in cypress.config.js.

2m read timeFrom glebbahmutov.com
Post cover image
6 Impressions