Example project of using Test Analytics from Codecov with Vitest Browser Mode.
In vitest.config.ts
, make sure to add juint
to the list of test reporters
and provide the outputFile
option to emit the report to the file system:
// vitest.config.ts
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
// ...other options
reporters: ['default', 'junit'],
outputFile: './test-report.junit.xml',
},
})
See full
vitest.config.ts
for reference.
Click here to install the Codecov GitHub app in your project.
Create a GitHub Actions workflow that will continuously run your tests and upload the test report to Codecov. Here's an example workflow:
# .github/workflows/ci.yml
jobs:
test:
runs-on: ubuntu-latest
steps:
# ...other steps
- name: Upload test results
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
See full
ci.yml
workflow for reference.
Use the "Repository upload token" as the value for the CODECOV_TOKEN
environment variable. You can find that value in the "Configuration > General" section of your project on Codecov:
Put that value as a new secret for GitHub Actions by going to your GitHub repository, "Settings > Secrets and variables > Actions" and click the "New repository secret" button.