JavaScript / TypeScript Testing
Framework Configuration
Any JavaScript/TypeScript test framework that can generate LCOV reports is supported. While we provide examples for Jest and Vitest below, you can use any framework of your choice (Mocha, AVA, Jasmine, etc.) as long as it generates coverage reports in LCOV format.
Key Requirements
- Coverage report must be in LCOV format
- Report must be saved as
coverage/lcov.info
- Report must be uploaded as a GitHub Actions artifact named
coverage-report
Jest
{
"scripts": {
"test": "jest"
}
}
/** @type {import('jest').Config} */
module.exports = {
collectCoverage: true,
coverageReporters: ["lcov"],
collectCoverageFrom: [
"**/*.{js,jsx,ts,tsx}",
"!**/*.d.ts",
"!**/node_modules/**"
]
}
Vitest
{
"scripts": {
"test": "vitest run --coverage"
}
}
/// <reference types="vitest" />
import { defineConfig } from 'vite'
// https://vitest.dev/guide/coverage.html#coverage-setup
export default defineConfig({
test: {
coverage: {
provider: 'v8',
reporter: ['lcov'],
},
},
})
Setting Up GitHub Actions
Create a workflow file in .github/workflows/
directory. The filename can be anything you prefer (e.g. coverage.yml
). Add the following content to your workflow file:
name: Test Coverage
on:
push:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install dependencies
run: npm ci
- name: Run tests with coverage
run: npm test
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/lcov.info
Key Configuration Points
- Configure your test framework to generate LCOV reports
- Upload the report as an artifact named
coverage-report
- Ensure the report is saved as
coverage/lcov.info
Viewing Coverage Reports
After your workflow runs successfully, GitAuto automatically processes the coverage reports and displays them in the Coverage Dashboard. The data updates whenever:
- You push to any branch (except master)
- You push additional commits to a pull request
- You manually trigger the workflow
About LCOV: LCOV (Linux Code Coverage) is a standard format for code coverage data. It's pronounced "el-cov" and is widely supported by various tools and services.