
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
vc-api-coverage
Advanced tools
A Vue Component API Coverage Tool.
A specialized Vitest reporter designed for Vue 3 TSX components that helps you track and improve your component API coverage. This tool analyzes and reports the usage coverage of your component's Props, Events, Slots, and Exposed methods in your tests.
'primary' | 'secondary' | 'tertiary' separately)npm install vc-api-coverage --save-dev
# or
yarn add -D vc-api-coverage
# or
pnpm add -D vc-api-coverage
// vitest.config.ts
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
reporters: ['vc-api-coverage']
}
})
vitest
The reporter will automatically generate coverage reports for your Vue 3 TSX components, showing which APIs are covered by your tests and which ones need attention.
The reporter supports several configuration options to customize its behavior:
// vitest.config.ts
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
reporters: [['vc-api-coverage', {
// Output directory for the coverage report
outputDir: 'coverage-api',
// Report formats: 'cli', 'html', 'json'
// You can specify multiple formats: ['cli', 'html']
format: ['cli', 'html', 'json'],
// Whether to open browser after generating HTML report
openBrowser: false,
// Include patterns: only analyze files matching these glob patterns
// Can be a single string or an array of strings
include: ['**/src/components/**/*.{tsx,vue}'],
// Exclude patterns: skip files matching these glob patterns
// Can be a single string or an array of strings
exclude: ['**/*.vue'],
// Strict mode: check each variant of union type props individually
// When enabled, props like 'variant: "primary" | "secondary" | "tertiary"'
// are tracked as 3 separate APIs instead of 1
// See docs/strict-mode.md for details
strict: false,
// Callback function executed when coverage report is completed
// Receives coverage data array where each item contains component coverage details
// Can be used for custom processing, CI integration, or enforcing coverage thresholds
onFinished: (data) => {
for (const item of data) {
if (item.total > item.covered) {
throw new Error(`${item.name} API Coverage is not 100%`)
}
}
}
}]]
}
})
This tool analyzes your Vue 3 TSX components by leveraging TypeScript's type system and AST analysis:
InstanceType<typeof Component>['$props']InstanceType<typeof Component>['$slots']defineExpose() and method name matching in testsExpose Detection: Uses a simple and reliable method name matching approach - scans test files for property access expressions (like wrapper.vm.focus()) and matches against exposed method names. This avoids complex variable tracking and V8 coverage dependency, resulting in better maintainability and accuracy.
For detailed implementation information, see Implementation Details.
╔═══════════════════╤══════════════╤═══════╤═════════╤═════════════════════════════════╗
║ Components │ Props/Events │ Slots │ Exposes │ Uncovered APIs ║
╟───────────────────┼──────────────┼───────┼─────────┼─────────────────────────────────╢
║ All │ 87% │ 100% │ 75% │ ║
╟───────────────────┼──────────────┼───────┼─────────┼─────────────────────────────────╢
║ button/Button.tsx │ 3/5 │ 2/2 │ 0/1 │ disabled, loading, onInfoclick ║
╟───────────────────┼──────────────┼───────┼─────────┼─────────────────────────────────╢
║ input/Input.tsx │ 10/10 │ 3/3 │ 3/3 │ ✔ ║
╚═══════════════════╧══════════════╧═══════╧═════════╧═════════════════════════════════╝

{
"summary": {
"totalComponents": 1,
"totalProps": 10,
"coveredProps": 8,
"totalSlots": 5,
"coveredSlots": 5,
"totalExposes": 4,
"coveredExposes": 0
},
"stats": {
"props": 80,
"slots": 100,
"methods": 0,
"total": 72
},
"components": [
{
"name": "Button.tsx",
"file": "src/components/button/Button.tsx",
"props": {
"total": 4,
"covered": 2,
"details": [
{
"name": "loading",
"covered": false
},
]
},
"slots": {
"total": 2,
"covered": 2,
"details": [
{
"name": "default",
"covered": true
},
]
},
"exposes": {
"total": 1,
"covered": 0,
"details": [
{
"name": "focus",
"covered": false
}
]
}
},
]
}
Strict mode enables more granular API coverage tracking by expanding union types and checking each variant individually.
In normal mode, the tool only checks if a prop is tested at all. In strict mode, it ensures that each possible value of a union type prop is tested, helping you achieve more thorough test coverage.
// Component definition
const buttonProps = {
variant: {
type: String as PropType<'primary' | 'secondary' | 'tertiary'>,
default: 'primary'
},
disabled: { type: Boolean, default: false }
}
Normal Mode - Checks if prop is tested with any value:
║ button/Button.tsx │ 2/2 │ Uncovered APIs: (none)
Strict Mode - Checks if each variant is tested:
║ button/Button.tsx │ 3/4 │ Uncovered APIs: variant[tertiary]
// vitest.config.ts
export default defineConfig({
test: {
reporters: [['vc-api-coverage', {
strict: true // Enable strict mode
}]]
}
})
| Type | Expansion Behavior | Example |
|---|---|---|
| Literal Union | Each value tracked separately | 'a' | 'b' | 'c' → [a], [b], [c] |
| Boolean | Only true tracked (false filtered) | boolean → [true] |
| Primitive Union | Each type tracked | string | number → [string], [number] |
| Optional Props | undefined filtered out | T | undefined → T only |
╔═══════════════════╤═══════════════╤═══════╤═════════╤════════════════════════════════╗
║ Components │ Props/Events │ Slots │ Exposes │ Uncovered APIs ║
╟───────────────────┼───────────────┼───────┼─────────┼────────────────────────────────╢
║ button/Button.tsx │ 5/10 │ 0/2 │ 0/1 │ variant[tertiary], ║
║ │ │ │ │ loading[true], ║
║ │ │ │ │ size, onInfoclick, ║
║ │ │ │ │ default, icon, focus ║
╚═══════════════════╧═══════════════╧═══════╧═════════╧════════════════════════════════╝
Notice how variant[tertiary] and loading[true] are tracked as individual variants.
For complete documentation, see Strict Mode Documentation.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT
FAQs
Vue Component API Coverage Reporter
The npm package vc-api-coverage receives a total of 0 weekly downloads. As such, vc-api-coverage popularity was classified as not popular.
We found that vc-api-coverage demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.