Skip to Content
DocumentationGetting StartedFirst Coverage Data

First Coverage Data

Note

Canyon provides installation guides for common frameworks to help you get started quickly.

Follow these steps to submit your first coverage data:

Start as a New Project

Installation

Babel is essential for modern frontend engineering and modular development. For Babel projects, you only need to install two Babel plugins to get started quickly.

npm install babel-plugin-istanbul babel-plugin-canyon -D

Add the istanbul and canyon plugins to your Babel configuration file :

babel.config.js
module.exports = { plugins: [ 'istanbul', 'canyon' // Note: The canyon plugin should come after the istanbul plugin ], };

Check

After configuration, start your project and print window.__coverage__ in the console. If the output matches the image below, it means code instrumentation was successful.

coverage-canyon-console

Configure CI Environment Variables

In the CI environment, we need to configure some environment variables to report coverage data.

Tip

Canyon detects pipeline variables during compilation and supports multiple pipeline providers.
Don’t see your pipeline provider? Try explicit configuration.

  1. DSN and REPORTER
  • DSN: Coverage data reporting service address, {{url}/coverage/client, where {{url}} is your Canyon service address.
  • REPORTER: User token, available in the Canyon user settings page.
  1. Configure CI Platform Variables

gitlab

ℹ️

Project ID, branch, and SHA do not need to be configured manually as the Canyon plugin will automatically detect pipeline environment variables.

Update Babel Plugin Activation Conditions

In the CI stage, we need to control when plugins are active to prevent instrumentation on production branches.

module.exports = { plugins: (process.env.CI && process.env.CI_COMMIT_REF_NAME !== 'release') ? [ 'canyon', 'istanbul' ]:[], };

Report Coverage Data

After CI completes, the page is deployed to the testing environment.

At this point, coverage data is stored in the browser. As users interact with the application or UI automation tests run, the window.coverage_ data will accumulate.

Reporting this data accurately to the Canyon server enables real-time display of coverage data.

Here are several ways to report coverage data: