test-quality-analysis
БесплатноБез исполняемых скриптовНе проверенDetect test smells, overmocking, flaky tests, coverage gaps, and tests that touch the real HOME or git config. Use when reviewing tests or analyzing test…
от laurigates★ 61 звезда на GitHubОб этом скилле
Test Quality Analysis
Expert knowledge for analyzing and improving test quality - detecting test smells, overmocking, insufficient coverage, and other testing anti-patterns.
When to Use This Skill
| Use this skill when... | Use another skill instead when... |
|---|---|
| Reviewing test quality and smells | Writing new unit tests (use vitest-testing) |
| Detecting overmocking or flaky tests | Setting up E2E tests (use playwright-testing) |
| Analyzing test coverage gaps | Validating tests via mutation (use mutation-testing) |
| Improving test maintainability | Generating test data (use property-based-testing) |
| Auditing test suites for anti-patterns | Writing Python tests (use python-testing) |
Core Expertise
Test Quality Dimensions
- Correctness: Tests verify the right behavior
- Reliability: Tests are deterministic and not flaky
- Maintainability: Tests are easy to understand and modify
- Performance: Tests run quickly
- Coverage: Tests cover critical code paths
- Isolation: Tests don't depend on external state
Test Smells - Quick Reference
| Smell | Symptom | Fix |
|---|---|---|
| Overmocking | 3+ mocks per test; mocking pure functions | Mock only I/O boundaries; use real implementations |
| Fragile tests | Break on refactor without behavior change | Test public APIs; use semantic selectors |
| Flaky tests | Non-deterministic pass/fail | Proper async/await; mock time; ensure isolation |
| Test duplication | Copy-pasted setup across tests | Extract to beforeEach(), fixtures, helpers |
| Slow tests | Suite > 10s for unit tests | beforeAll() for expensive setup; parallelize |
| Poor assertions | toBeDefined(), no assertions, mock-only assertions |
Specific matchers; assert outputs and state |
| Insufficient coverage | Critical paths untested | 80%+ on business logic; test error paths and boundaries |
| Real user environment | Test spawns git/CLIs or touches config with the developer's HOME |
Temp HOME + XDG_*_HOME + GIT_CONFIG_GLOBAL; see Tests That Reach the Real User Environment |
Analysis Tools
TypeScript/JavaScript
vitest --coverage # Coverage report
vitest --coverage --coverage.thresholds.lines=80 # Threshold check
vitest --reporter=verbose # Find slow tests
Python
uv run pytest --cov --cov-report=term-missing # Coverage with missing lines
uv run pytest --cov --cov-fail-under=80 # Threshold check
uv run pytest --durations=10 # Find slow tests
Key Anti-Patterns
Testing Implementation vs Behavior
// BAD: Testing how
test('uses correct algorithm', () => {
const spy = vi.spyOn(Math, 'sqrt')
calculateDistance({ x: 0, y: 0 }, { x: 3, y: 4 })
expect(spy).toHaveBeenCalled()
})
// GOOD: Testing what
test('calculates distance correctly', () => {
const distance = calculateDistance({ x: 0, y: 0 }, { x: 3, y: 4 })
expect(distance).toBe(5)
})
Weak Assertions
// BAD
expect(users).toBeDefined() // Too vague
expect(mockAPI).toHaveBeenCalled() // Testing mock, not behavior
// GOOD
expect(user).toMatchObject({
id: expect.any(Number),
name: 'John',
email: '[email protected]',
})
Missing Coverage
// BAD: Only tests happy path
test('applies discount', () => {
expect(calculateDiscount(100, 'SAVE20')).toBe(80)
})
// GOOD: Tests all paths
describe('calculateDiscount', () => {
it('applies SAVE20', () => expect(calculateDiscount(100, 'SAVE20')).toBe(80))
it('applies SAVE50', () => expect(calculateDiscount(100, 'SAVE50')).toBe(50))
it('invalid coupon', () => expect(calculateDiscount(100, 'INVALID')).toBe(100))
it('no coupon', () => expect(calculateDiscount(100)).toBe(100))
})
Tests That Reach the Real User Environment
A test that spawns git, gh, or any CLI with a login, or that reads or writes config, credentials or tokens, inherits the developer's real home directory. A cleanup or logout step in such a test can delete the live login. Point every user-level location at a temp dir before the first spawn:
| Variable | Why |
|---|---|
HOME |
~, os.homedir() (Node) and Path.home() resolve from it on POSIX |
XDG_CONFIG_HOME, XDG_DATA_HOME, XDG_STATE_HOME, XDG_CACHE_HOME |
An exported value is an absolute path and survives a HOME change. git reads $XDG_CONFIG_HOME/git/config; gh keeps hosts.yml under it. With XDG_CONFIG_HOME=~/.config exported, HOME=$(mktemp -d) gh auth status still lists the real account |
GIT_CONFIG_GLOBAL |
Replaces both global files (~/.gitconfig and the XDG one). Point it at a file in the temp dir so git config --global writes land there |
GIT_CONFIG_NOSYSTEM=1 |
Skips the system-level config |
Also unset the GIT_DIR family, wh
Установить test-quality-analysis в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Bash(vitest *)Bash(uv run pytest *)Bash(npx playwright test *)ReadEditWriteGrepGlobTodoWriteВложенные файлы
FAQ
Что делает скилл test-quality-analysis?
Detect test smells, overmocking, flaky tests, coverage gaps, and tests that touch the real HOME or git config. Use when reviewing tests or analyzing test effectiveness and reliability.
Как установить скилл test-quality-analysis?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл test-quality-analysis запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic