@circleci/vitest-circleci-coverage
v0.3.707
Published
A Vitest plugin that generates coverage data for CircleCI's Smarter Testing.
Keywords
Readme
vitest-circleci-coverage
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 @circleci/vitest-circleci-coverageAdd 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 runBrowser mode
Browser mode collects coverage over the Chrome DevTools Protocol. A Chromium browser is required.
import { defineConfig } from 'vitest/config';
import { playwright } from '@vitest/browser-playwright';
export default defineConfig({
test: {
setupFiles: ['@circleci/vitest-circleci-coverage/browser'],
reporters: ['@circleci/vitest-circleci-coverage/reporter'],
browser: {
enabled: true,
provider: playwright(),
instances: [{ browser: 'chromium' }],
},
},
});Development
Install and use current node version.
NODE_VER=$(cat ./.nvmrc)
nvm install $NODE_VER
nvm use $NODE_VERInstall dependencies with pnpm.
pnpm installBuild the plugin.
pnpm buildRun tests.
pnpm test