Command Palette

Search for a command to run...

Назад к скиллам
скилл № 85162

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от 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:

  1. Write specs - patterns below; detail in references/web-realness.md
  2. Prioritize - npm run test:risk before 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.js mirroring src/app/ (not co-located)
  • describe('@/utils/itemid', ...) or view/component name
  • @/ -> src/app/; @@/ -> specs/app/mocks/
  • Config: vite.config.js -> test block; 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

Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • 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 запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить test-coverage с