Skip to content

A Jest plugin that generates coverage data for CircleCI's Smarter Testing.

License

Notifications You must be signed in to change notification settings

circleci/jest-circleci-coverage

Repository files navigation

jest-circleci-coverage

A Jest plugin that generates coverage data for CircleCI's Smarter Testing.

Usage

This plugin uses the v8 JS engine Profiler APIs to collect coverage.

Install the plugin.

pnpm add -D jest-circleci-coverage

Add the custom runner and reporter to your jest.config.ts:

import {createDefaultPreset} from 'ts-jest';
import type {Config} from 'jest';

const tsJestTransformCfg = createDefaultPreset().transform;

const config: Config = {
  testEnvironment: 'jest-circleci-coverage/environment',
  reporters: ['default', 'jest-circleci-coverage/reporter'],
  transform: {
    ...tsJestTransformCfg,
  },
};

export default config;

Set the CIRCLECI_COVERAGE environment variable when running tests to enable test coverage.

CIRCLECI_COVERAGE=coverage.json jest

Development

Install and use current node version.

NODE_VER=$(cat ./.nvmrc)
nvm install $NODE_VER
nvm use $NODE_VER

Install dependencies with pnpm.

pnpm install

Build the plugin.

pnpm build

Run tests.

pnpm test

About

A Jest plugin that generates coverage data for CircleCI's Smarter Testing.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •