manbearwiz / vitest-tiny-reporter

MIT License
0 stars 0 forks source link

vitest-tiny-reporter

npm npm bundle size NPM npm GitHub issues semantic-release: angular

vitest-tiny-reporter is a minimal reporter for Vitest that provides the most essential information about the test run. This is very useful with tools like lefthook that run several checks in parallel, where you want to see the test results without scrolling through a lot of output.

Installation

npm install --save vitest-tiny-reporter

Usage

You can specify the reporter in your vitest.config.ts:

import type { UserConfig } from 'vitest/config';
import TinyReporter from 'vite-tiny-reporter';

export default {
  test: {
    reporters: [new TinyReporter()],
  },
} satisfies UserConfig;

Or you can use the reporter from the command line:

vitest --reporter vitest-tiny-reporter

Or with lefthook:

pre-commit:
  parallel: true
  commands:
    test:
      glob: "*.ts"
      run: npx vitest related --reporter=vitest-tiny-reporter --run {staged_files}
      fail_text: "Tests failed"
      env:
        TERM: dumb

Output

Shell

In a shell, the output will look like this:

$ vitest
 ✖ FAIL  1 test failed
 Test Files  1 failed (1)
      Tests  1 failed | 10 passed (11)

VSCode

When used with lefthook and committing in the VSCode UI, vitest-tiny-reporter shows actual usefull information.

Default reporter:

image

Tiny reporter:

image