Skip to content

feat!: read code coverage config from Cypress.expose instead of Cypress.env#972

Merged
cacieprins merged 25 commits intomasterfrom
breaking/cy-expose-config
Feb 10, 2026
Merged

feat!: read code coverage config from Cypress.expose instead of Cypress.env#972
cacieprins merged 25 commits intomasterfrom
breaking/cy-expose-config

Conversation

@cacieprins
Copy link
Contributor

@cacieprins cacieprins commented Jan 30, 2026

BREAKING CHANGE: @cypress/code-coverage configuration must now be placed under expose instead of env in your Cypress configuration.

Migrate from Cypress.env() to Cypress.expose()

This PR migrates @cypress/code-coverage's configuration from Cypress.env() to Cypress.expose() in response to the deprecation of Cypress.env() in Cypress v15.10.0. Cypress.env() will be removed in Cypress 16, necessitating this breaking change. For more details about why Cypress has deprecated Cypress.env(), see the official documentation on migrating from Cypress.env() to Cypress.expose().

What Changed

  • Configuration location: This plugin is now configured via the expose key in your Cypress configuration, rather than the env key.
  • API access: All internal references to Cypress.env() replaced with Cypress.expose()

Migration

Before:

// cypress.config.js
const { defineConfig } = require('cypress')

module.exports = defineConfig({
  env: {
    codeCoverage: {
      url: 'http://localhost:3000/__coverage__',
      exclude: ['cypress/**/*.*'],
      expectBackendCoverageOnly: true
    },
    sendCoverageBatchSize: 1000,
    coverage: false
  }
})

After:

// cypress.config.js
const { defineConfig } = require('cypress')

module.exports = defineConfig({
  expose: {
    codeCoverage: {
      url: 'http://localhost:3000/__coverage__',
      exclude: ['cypress/**/*.*'],
      expectBackendCoverageOnly: true
    },
    sendCoverageBatchSize: 1000,
    coverage: false
  }
})

CLI usage:

# Before
cypress run --env coverage=false

# After
cypress run --expose coverage=false

Additional Changes

Impact

  • Breaking: Existing configurations using env.codeCoverage will no longer work
  • Compatibility: Requires Cypress >=15.10.0. Requires Node >=20.
  • Migration path: Clear migration guide provided in README

See the migration guide in the README for detailed migration instructions.


Note

High Risk
Breaking API change that affects all consumers’ Cypress configuration and touches core coverage collection/reporting paths; incorrect expose setup could silently disable coverage or alter reporting behavior.

Overview
Breaking change: @cypress/code-coverage now reads all runtime configuration (including codeCoverage, coverage, and sendCoverageBatchSize) from Cypress.expose() / config.expose instead of Cypress.env() / config.env, and sets the codeCoverageTasksRegistered flag via config.expose.

The plugin implementation is refactored to TypeScript across core modules (lib/task, lib/task-utils, lib/common-utils) and middleware, adds a shared lib/plugins.ts entrypoint, and updates backend coverage middleware to return null when coverage is unavailable.

Test/CI plumbing is updated: CircleCI moves to newer Cypress orb and Node images, adds a build-dist step gating matrix test-app verification and Windows runs, and repository Cypress e2e test scaffolding is removed in favor of the new unit-test setup; docs and example configs are updated to use expose (including a new 3.x→4.x migration section), and test-apps/*/package-lock.json is gitignored.

Written by Cursor Bugbot for commit 2455c9b. This will update automatically on new commits. Configure here.

@mschile
Copy link
Contributor

mschile commented Jan 30, 2026

Searching for 'env' shows other mentions of 'env' that we probably want to update as well.

Copy link
Contributor

@mschile mschile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple comments.

@cacieprins cacieprins requested a review from mschile February 4, 2026 19:03
@cacieprins cacieprins force-pushed the breaking/cy-expose-config branch from 349201b to b608a9c Compare February 4, 2026 20:54
@cacieprins cacieprins force-pushed the breaking/cy-expose-config branch from 3506852 to 141cadd Compare February 4, 2026 22:04
@cacieprins cacieprins self-assigned this Feb 5, 2026
scytacki added a commit to concord-consortium/starter-projects that referenced this pull request Feb 5, 2026
- globals 16→17, wait-on 8→9, cross-env 7→10
- @stylistic/eslint-plugin 4→5, removed deprecated @stylistic/eslint-plugin-js
  and @stylistic/eslint-plugin-jsx sub-packages, migrated rule prefixes
- eslint-plugin-jest 28→29, eslint-plugin-react-hooks 5→7 (updated to flat
  config format), eslint-plugin-cypress 4→5
- jest 29→30, jest-environment-jsdom 29→30, @types/jest 29→30
- cypress 14→15, @cypress/webpack-preprocessor 6→7
- Updated cypress-coverage.md to reflect current config file locations
- Added docs/dependency-notes.md tracking @cypress/code-coverage Cypress.env()
  deprecation warning (awaiting upstream fix in cypress-io/code-coverage#972)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cacieprins
Copy link
Contributor Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@cacieprins cacieprins merged commit 8ec0991 into master Feb 10, 2026
28 checks passed
@cacieprins cacieprins deleted the breaking/cy-expose-config branch February 10, 2026 18:05
@cacieprins cacieprins restored the breaking/cy-expose-config branch February 10, 2026 18:30
@cacieprins cacieprins deleted the breaking/cy-expose-config branch February 10, 2026 18:36
@cypress-app-bot
Copy link

🎉 This PR is included in version 4.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants