Skip to content

Cypress test coverage

Cypress test coverage that reaches past the browser

Cypress code coverage usually means front-end coverage: the app is instrumented and the plugin merges what ran in the browser. The services the app calls are not in that report. CoverOps adds them: a Cypress plugin labels every request with the running test, agents in your services record the code it ran, and each test gets its backend lines, methods and services.

By the CoverOps team · Last updated

Why teams choose CoverOps for Cypress test coverage

  • Coverage past the network tab

    Line-level coverage of the services your app calls, per Cypress test, next to the front-end coverage you already have. One plugin and two calls in the support file.

    See what a test's footprint shows

  • Skip tests safely, with a reason for every skip

    A test is skipped only when its recorded footprint misses every changed line, and the report says why. Observation mode shows what would have been skipped before anything is, and when the change cannot be read in full, everything runs.

    Read the test selection guide

  • A merge gate on the code that changed

    Block or flag a pull request when its changed lines were not executed by the tests of its build, with the verdict on the commit status and, on GitHub, a comment listing the lines no test ran.

    Read the quality gate guide

  • Flaky tests caught, not hidden by retries

    Passes on retry, different results on one commit and flips on a branch are all counted, flips per branch, and a confirmed flake can be quarantined so it stops blocking builds.

    Read the flaky tests guide

  • Cloud, self-hosted or air-gapped

    Use the hosted service in AWS Frankfurt, or run CoverOps in your private cloud, on your own servers or fully offline.

    Security and data handling

  • ISO/IEC 27001, 27701 and ISO 9001

    Certified to ISO/IEC 27001:2022, ISO/IEC 27701 and ISO 9001. SOC 2 Type 2 is coming soon.

    Certifications and security

What the usual Cypress coverage report leaves out

The standard way to measure Cypress coverage is to instrument the front-end build, let the code-coverage plugin collect counters from the browser after each test, and merge them into one report. It answers which components, hooks and client-side functions your end-to-end tests exercised, and it is worth keeping.

It cannot see past the network tab. A Cypress test that places an order runs an API handler, a pricing service, maybe a queue consumer, and none of that is in a browser coverage report. Some setups instrument the backend too and merge a second report after the run, but that gives one number for the whole suite, not what each test reached, and not across several services.

Per-test backend coverage is what lets you skip the Cypress specs a change cannot reach and see what a failing test did on the server. That is the part CoverOps measures.

How it works with Cypress

  1. Start the services under test with the CoverOps agent for their language: Java, .NET, Node.js, Python, Go or PHP.
  2. Install @coverageops/cypress from your CoverOps address and return coverageOpsPlugin(on, config) from setupNodeEvents. It opens the run, hands its key to the browser, and posts every verdict after the run.
  3. In the support file, call selectionSkip() and then labelRequests(). Every request the app makes while a test runs carries the test's spec::title, its optional id and the run.
  4. Set COVERAGEOPS_ENDPOINT and COVERAGEOPS_TOKEN in CI. For a parallel run across several machines, set COVERAGEOPS_RUN_PARTS to the number of machines so the run waits for all of them.
cypress.config.js
const { coverageOpsPlugin } = require('@coverageops/cypress');
module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      return coverageOpsPlugin(on, config);
    },
  },
});
cypress/support/e2e.js
const { selectionSkip, labelRequests } = require('@coverageops/cypress/support');
selectionSkip();   // skip what the change cannot reach
labelRequests();   // label every request the app makes
Optional: the test's id in TestRail / Jira
it('pays by card', { expose: { coverageopsTestId: 'AUT-45' } }, () => { … });
// env instead of expose before Cypress 15.10

Cypress 13 to 16 are supported. Cypress keeps only the last before:run and after:run handler, so if your config registers its own, chain them (for example with cypress-on-fix).

What you get

Each spec's backend footprint

The end-of-run summary prints every failed test with a link to what it did on the backend, and the run page lists each test's endpoints, services, methods and lines.

Read the guide

Skip the tests a change cannot reach

coverageops select --format skip writes a skip list; with COVERAGEOPS_SKIP_FILE pointing at it, selectionSkip() skips those tests before they visit a page or run a hook. No file, an empty file or an unreadable one means everything runs.

Read the guide

A changed-code gate

Of the lines a pull request changed, how many did the tests of its build execute? coverageops gate answers in CI and can post the verdict as a commit status on GitHub, GitLab, Azure DevOps or Bitbucket.

Read the guide

Retries as flakiness evidence

With retries in the config, each verdict carries its attempts. A pass on retry still passes the run and the gate, and the Flaky tests page counts it as flaky in that run.

Read the guide

What is measured, and what is not

Measured

  • Server-side lines, methods and services each Cypress test reached, on every service with an agent.
  • Requests the application makes in the browser during a test, page loads included, each labelled with that test.
  • Every verdict, one per test identity, with attempts, branch and commit.

Not measured

  • Your front-end code in the browser. Keep the code-coverage plugin for that; CoverOps has no browser agent.
  • Component tests that never call a backend: there is nothing on the server for them to reach.
  • Exact lines per test when tests from parallel machines hit the same service process at once; lines of the shared span go to each overlapping test, and the run page says so.

Frequently asked questions

Does CoverOps replace the Cypress code-coverage plugin?

No. The plugin measures front-end code in the browser; CoverOps measures the services behind it. They answer different halves of the question and can run side by side.

How are requests linked to the Cypress test that made them?

labelRequests() adds the X-CoverageOps-Test, X-CoverageOps-Test-Id and X-CoverageOps-Run headers to every request the app makes while a test runs. The agent in the service reads them and passes them on to the services it calls.

Does it work with parallel Cypress runs?

Yes. Every machine reports into the same run key. Cypress does not tell a plugin how many machines there are, so set COVERAGEOPS_RUN_PARTS on each, or let the pipeline close the run with coverageops run finish.

Which Cypress versions are supported?

Cypress 13 to 16. The plugin passes the run and the skip list through expose where Cypress has it (15.10 and later) and through env for older versions.

Measure what your Cypress suite runs on the server

Bring a Cypress spec and one service to a demo; we show the backend footprint of every test.