Vitest Integration with Mergify
Report your test results from Vitest to Mergify
This guide explains how to integrate Vitest with Test
Insights using the @mergifyio/vitest reporter. Once installed, test results
are automatically uploaded to Test Insights without any extra workflow changes.
Installation
Section titled InstallationYou need to install the
@mergifyio/vitest package
to automatically upload your test results to Test Insights.
npm install --save-dev @mergifyio/vitestyarn add --dev @mergifyio/vitestpnpm add --save-dev @mergifyio/vitestConfiguration
Section titled ConfigurationAdd the Mergify reporter to your vitest.config.ts (or vite.config.ts):
import { defineConfig } from 'vitest/config';import MergifyReporter from '@mergifyio/vitest';
export default defineConfig({ test: { reporters: ['default', new MergifyReporter()], },});The 'default' reporter keeps the standard console output alongside the
Mergify reporter.
Update Your CI Workflow
Section titled Update Your CI WorkflowYour workflow should run your tests as usual while exporting the secret
MERGIFY_TOKEN as an environment variable.
GitHub Actions
Section titled GitHub ActionsAdd the following to the GitHub Actions step running your tests:
env: MERGIFY_TOKEN: ${{ secrets.MERGIFY_TOKEN }}For example:
- name: Run Tests 🧪 env: MERGIFY_TOKEN: ${{ secrets.MERGIFY_TOKEN }} run: npm testBuildkite
Section titled BuildkiteSet MERGIFY_TOKEN as an environment variable in your pipeline step:
steps: - label: "Run Tests 🧪" command: npm test env: MERGIFY_TOKEN: "${MERGIFY_TOKEN}"The reporter automatically collects your test results and sends them to Test Insights.
Check the Test Insights dashboard afterward to view execution metrics, detect flaky tests, and review test trends.
Environment Variables
Section titled Environment Variables| Variable | Purpose | Default |
|---|---|---|
MERGIFY_TOKEN | API authentication token | Required |
MERGIFY_API_URL | API endpoint location | https://api.mergify.com |
VITEST_MERGIFY_ENABLE | Force-enable outside CI | false |
VITEST_MERGIFY_DEBUG | Print spans to console | false |
MERGIFY_TRACEPARENT | W3C distributed trace context | Optional |
MERGIFY_TEST_JOB_NAME | Test job name identifier | Optional |
Was this page helpful?
Thanks for your feedback!