Skip to content

Latest commit

 

History

History
63 lines (43 loc) · 1.14 KB

File metadata and controls

63 lines (43 loc) · 1.14 KB

vitest-circleci-coverage

JSR

A Vitest 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 jsr:@circleci/vitest-circleci-coverage

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

import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    runner: '@circleci/vitest-circleci-coverage/runner',
    reporters: ['@circleci/vitest-circleci-coverage/reporter'],
  },
});

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

CIRCLECI_COVERAGE=coverage.json vitest run

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