Instrumenting Cypress tests with Helios

Use the installation instructions below if you're using Cypress as your testing framework and would like to add your existing tests to Helios for complete E2E troubleshooting.

Instrument existing tests

Navigate to your project's root directory, and install the latest Helios OpenTelemetry and Cypress SDKs:

npm install --save-dev helios-cypress-sdk
npm install --save-dev helios-opentelemetry-sdk

In your test file, paste the following code snippet before ALL other imports:

const { initialize } = require('helios-cypress-sdk');

initialize({ apiToken: <API_TOKEN> });
import { initialize } from 'helios-cypress-sdk';

initialize({ apiToken: <API_TOKEN> });

In your Cypress plugins.js file, embed the following snippet:

const { initializeCypressPlugins } = require('helios-opentelemetry-sdk');

const { heliosFlushSpans, heliosTasks } = initializeCypressPlugins({ apiToken: <API_TOKEN> });

module.exports = (on, config) => {
    on('after:run', heliosFlushSpans);
    on('task', {
        ...heliosTasks
    });
};

Configuring CI parameters

In order to provide the CI context of your Cypress tests, add the following attributes to the initializeCypressPlugins function call:

const { initializeCypressPlugins } = require('helios-opentelemetry-sdk');

const { heliosFlushSpans, heliosTasks } = initializeCypressPlugins({
    apiToken: <API_TOKEN>,
    ciJobId: <CI_JOB_ID>, // Optional
    ciJobName: <CI_JOB_NAME>, // Optional
    ciJobUrl: <CI_JOB_URL> // Optional
});

๐Ÿ‘

All set

Now when you run your tests - the results will show up in the Helios application.

Read more about the challenges distributed architectures present to UI testing tools and how Helios solves them with E2E visibility using context propagation.

๐Ÿ’š

Cypress