Generating a pretty Markdown report for Vitest, based on jest-md-dashboard, markdown design heavily inspired by Test Reporter.
See #1
pnpm install -D vitest-markdown-reporter
Add reporters
field in vitest.config.ts
or under test
in vite.config.ts
.
/// <reference types="vitest" />
import { defineConfig } from "vite";
import { VitestMarkdownReporter } from "vitest-markdown-reporter";
export default defineConfig({
test: {
reporters: ["default", new VitestMarkdownReporter()],
outputFile: {
markdown: "test-report.md",
},
},
});
Run vitest and the report will be saved to test-report.md
. If neither Vitest's native outputFile
option nor this library's own is used, the report will instead be printed to the console.
With options
/// <reference types="vitest" />
import { defineConfig } from "vite";
import { VitestMarkdownReporter } from "vitest-markdown-reporter";
export default defineConfig({
test: {
reporters: [
"default",
new VitestMarkdownReporter({ title: "My Test Report" }),
],
outputFile: {
markdown: "test-report.md",
},
},
});
Name | Type | Default | Description |
---|---|---|---|
title |
string |
"Test Report" |
The title of the report. It will be printed at the top of the markdown output. |
outputPath |
string |
undefined |
The file path to save the report to. |
permalinkBaseUrl |
string |
undefined |
Override baseUrl of permalink. See Permalink section for more information. |
enableGithubActionsSummary |
boolean |
true |
Enable GitHub Actions summary when running in CI. |
flat |
boolean |
true |
Flatten Test suites in report. |
vitest-markdown-reporter generates permalinks to test files on GitHub (or other services) by default.
It tries to find git information from the following sources.
permalinkBaseUrl
option- (on GitHub Actions) environment variables
- (in git repository) repository config
If permalinkBaseUrl
is supplied vitest-markdown-reporter will use it to generate permalinks.
Specify this option when if generated permalinks are incorrect.
The URL must have a trailing slash.
e.g. https://github.com/pecirep/vitest-markdown-reporter/blob/
If vitest runs on GitHub Actions, vitest-markdown-reporter refers to the the environment variables.
If vitest runs in a git repository, vitest-markdown-reporter refers to the local repository config.
We appreciate your help!