test-coverage
Write Vitest specs for Vue 3 JavaScript (Vite Plus, happy-dom, @vue/test-utils) and analyze V8 coverage + Fallow health to prioritize test-first refactors…
от realness-online★ 20 звёзд на GitHub
Установить test-coverage в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Tests, coverage, and refactor risk
Canonical reference: apps/realness (@realness.online/web). Run every
command below from that directory.
Match specs/app/**/*.spec.js there. Do not introduce Jest, React Testing Library, TypeScript test files, or co-located *.test.ts.
Two jobs:
- Write specs - patterns below; detail in references/web-realness.md
- Prioritize -
npm run test:riskbefore refactors; not a blind chase for 100%
Stack
| Piece | What we use |
|---|---|
| Runner | Vite Plus - vp test, import ... from 'vite-plus/test' |
| Engine | Vitest (vite-plus-test alias) |
| DOM | happy-dom |
| Vue | @vue/test-utils - prefer shallowMount |
| Language | JavaScript + JSDoc |
| Coverage | V8, 80% global, all: true |
Commands
vp test run --reporter=dot # npm run test
vp test watch # npm run test:watch
vp test run --coverage # npm run test:coverage
vp test run --bail=1 --reporter=dot # npm run test:fail-fast
npm run test:risk # coverage + fallow + risk report
Pre-commit: vp check --fix && vp run type && vp test run.
Writing specs
Layout
- All specs in
specs/app/**/*.spec.jsmirroringsrc/app/(not co-located) describe('@/utils/itemid', ...)or view/component name@/->src/app/;@@/->specs/app/mocks/- Config:
vite.config.js->testblock; setup:specs/app/setup.js,specs/app/mocks/
Skeleton
import { describe, it, expect, vi, beforeEach } from 'vite-plus/test'
import { fn_under_test } from '@/utils/example'
describe('@/utils/example', () => {
beforeEach(() => {
vi.clearAllMocks()
})
it('describes behavior in plain language', () => {
expect(fn_under_test('input')).toBe('output')
})
})
Test behavior, not internals (JS style: AGENTS.md).
Key patterns
| Pattern | Approach | Reference spec |
|---|---|---|
| Pure utils | Input/output, nested describe |
specs/app/utils/itemid.spec.js |
| Module mocks | Top-level vi.mock(); vi.clearAllMocks() in beforeEach |
specs/app/utils/itemid.spec.js |
| Vue components | shallowMount, stubs, semantic queries |
specs/app/components/account/as-notifications.spec.js |
| Composable mocks | vi.hoisted() refs for vi.mock closures |
specs/app/views/Account.spec.js |
| Composables | with_setup() + mount(defineComponent(...)) |
specs/app/use/poster.spec.js |
| Async errors | await expect(...).rejects.toThrow() |
specs/app/utils/itemid.spec.js |
Hoisted mocks (reset .value in beforeEach):
const { mock_status, mock_enable } = vi.hoisted(() => {
const create_ref = value => ({ value, __v_isRef: true })
return {
mock_status: create_ref('off'),
mock_enable: vi.fn().mockResolvedValue(true)
}
})
vi.mock('@/use/push', () => ({
use_push: () => ({ status: mock_status, enable: mock_enable })
}))
Global mocks: specs/app/mocks/default.js, specs/app/mocks/browser/*. Per-spec mocks only when behavior differs.
mockReset: false in config - mocks keep implementations; clear call history each test.
What we do not do
| Avoid | Use instead |
|---|---|
| Jest / React Testing Library | vite-plus/test + @vue/test-utils |
| TypeScript test files | .spec.js + JSDoc |
@faker-js/faker |
Domain fixtures (item IDs, directories) |
| supertest / live DB | Mock idb-keyval, serverless |
data-testid |
Semantic DOM queries |
| 100% coverage | 80% gate + risk report |
Full patterns, templates, file map: references/web-realness.md
Coverage workflow
1. Risk report (start here)
npm run test:risk
# or, if reports already exist:
npm run test:risk:report
Runs scripts/prioritize-refactor-risk.js.
- Delete or wire - fallow
unused-files; do not add tests - Test before refactor - ranked by coverage gap + CRAP + fan-in + hotspots + P0/P1
Options: `--thresh
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/fallow-integration.md
- references/web-realness.md
- scripts/lib/coverage-metrics.js
- scripts/lib/risk.js
- scripts/lib/risk.test.js
- scripts/prioritize-refactor-risk.js
- scripts/summarize-coverage.js
FAQ
Что делает скилл test-coverage?
Write Vitest specs for Vue 3 JavaScript (Vite Plus, happy-dom, @vue/test-utils) and analyze V8 coverage + Fallow health to prioritize test-first refactors. Reference implementation is apps/realness. Use when asked to "write tests for this", "raise coverage", or after test:coverage or npx fallow fails thresholds.
Как установить скилл test-coverage?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл test-coverage запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…