-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
Description
User story
Our setup wizard should be able to configure a basic working version of each of our official plugins. Each plugin may prompt for its own specific configuration options and infer smart defaults from the user's repo. The resulting configuration code adds the plugin to the user's config and sets up some basic categories.
This issue is about @code-pushup/coverage-plugin specifically.
Output example
import coveragePlugin from '@code-pushup/coverage-plugin';
import type { CoreConfig } from '@code-pushup/models';
const config: CoreConfig = {
plugins: [
await coveragePlugin({
coverageToolCommand: 'npx vitest run --coverage.enabled',
reports: ['coverage/lcov.info'],
}),
],
categories: [
{
slug: 'code-coverage',
title: 'Code coverage',
description: 'Measures how much of your code is **covered by tests**.',
refs: [
{ type: 'group', plugin: 'coverage', slug: 'coverage', weight: 1 },
],
},
],
};
export default config;Acceptance criteria
- The Coverage plugin is auto-selected if
jestorvitestis installed or anjest.configorvitest.config/vite.config/vitest.workspacefile exists in the root directory (with extensions matching/[mc]?[tj]s/regex). Otherwise, it is unselected by default. - The user is prompted (or provides a CLI argument) for their test framework.
- The options are Jest, Vitest or other. The default value depends on whether installed packages or config files are detected. If neither Jest nor Vitest is detected, then the default is "other".
- If Jest or Vitest is selected, then coverage is configured, and the test command is derived.
- The coverage settings are checked in the Jest/Vitest config file. If coverage isn't configured or the output format doesn't include LCOV, then the Jest/Vitest config file is adjusted accordingly.
- The plugin's test command is set to
jest --coverageorvitest run --coverage.enabled. - The plugin's report path is set to match the Jest/Vitest config file.
- If none of the predefined test frameworks are selected ("other"), then the user is prompted to provide the necessary configuration (no smart suggestions).
- At minimum, a report path must be provided.
- Optionally, the user may also provide a test command (e.g.,
yarn test:coverage).
- The user should confirm (via prompt or CLI argument) if they want to collect all coverage types, or select a subset.
- The user should confirm (via prompt or CLI argument) if they want to continue on test command failure.
- The user should confirm (via prompt or CLI argument) if they want to also generate basic categories.
- The default answer is yes (create the categories).
- If confirmed, 1 category is created - Code coverage (from
coveragegroup). - If denied, no categories are created.
- All of the above logic lives in
@code-pushup/coverage-plugin. The core of the setup wizard in@code-pushup/create-cliorchestrates plugin selection and generation, but doesn't know any specifics about individual plugins.
Reactions are currently unavailable