🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@sentry/jest-environment

Package Overview
Dependencies
Maintainers
10
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/jest-environment

Automatic performance and profiling instrumentation for your jest tests.

6.1.0
latest
Source
npm
Version published
Weekly downloads
2.4K
-19.4%
Maintainers
10
Weekly downloads
 
Created
Source

jest-sentry-environment

Adds Sentry performance monitoring to your jest test suites to find your slowest tests.

Sentry Example

Installation

First, you will need to add the jest-sentry-environment package to your application, as well as the Sentry SDKs.

npm install @sentry/node @sentry/tracing @sentry/profiling-node jest-sentry-environment

Then, in your jest configuration file, e.g. jest.config.js you will need to specify the path to the environment as well as some options.

{
  testEnvironment: '@sentry/jest-environment/jsdom', // or `@sentry/jest-environment/node` for node environment
  testEnvironmentOptions: {
    sentryConfig: {
      // `init` will be passed to `Sentry.init()`
      init: {
        dsn: '<your DSN here>'
        environment: !!process.env.CI ? 'ci' : 'local',
        tracesSampleRate: 1,
        profilesSampleRate: 1
      },

      transactionOptions: {
        // `tags` will be used for the test suite transaction
        tags: {
          branch: process.env.GITHUB_REF,
          commit: process.env.GITHUB_SHA,
        },
      },
    },
  },
}

You can either import the jsdom or node environments. You can also customize the base environment by specifying your own testEnvironment.

testEnvironment: './path/to/env.js',

In ./path/to/env.js:

const {createEnvironment} = require('jest-sentry-environment');

return createEnvironment({
  baseEnvironment: require('jest-environment-node'),
});

Keywords

sentry

FAQs

Package last updated on 11 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts