Jest

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

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

npm install --save @heliosphere/opentelemetry-sdk

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

const { instrumentTests } = require('@heliosphere/opentelemetry-sdk');

instrumentTests({
    apiToken: <API_TOKEN>,
    environment: <ENVIRONMENT>,  // Defaults to process.env.NODE_ENV if omitted.
});
import { instrumentTests } from '@heliosphere/opentelemetry-sdk';

instrumentTests({
    apiToken: <API_TOKEN>,
    environment: <ENVIRONMENT>,  // Defaults to process.env.NODE_ENV if omitted.
});

πŸ“˜

jest-circus

Make sure to complete the step below to complete the installation if you're using the jest-circus runner (which is the default runner in Jest 27 and above). Specifically, testEnvironment needs to be referenced.

Add a reference to Helios testEnvironment by adding the following annotation to the top of your test file:

/**
 * @jest-environment @heliosphere/opentelemetry-instrumentation-jest
 */

Another option is to point to the module using:
--env CLI option

πŸ‘

All set

Now when you run your tests - the results will show up in the Helios application and the URL of the exact test trace will be handily printed after each test run.


Did this page help you?