No slash command · from testing-plugin
Detects test smells, overmocking, flaky tests, coverage gaps, and tests that touch real user environments. Use when reviewing test suites or analyzing test effectiveness and reliability.
Ships in testing-plugin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Expert knowledge for analyzing and improving test quality - detecting test smells, overmocking, insufficient coverage, and other testing anti-patterns.
| 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) |
Test Quality Dimensions
| 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 |
vitest --coverage # Coverage report
vitest --coverage --coverage.thresholds.lines=80 # Threshold check
vitest --reporter=verbose # Find slow tests
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
// 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)
})
// 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]',
})
// 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))
})
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, which overrides git -C <sandbox> — see issue #1745 for the list and why a partial unset is not enough. OS keychains (macOS Keychain, gh's keyring store) live outside HOME, so a test of login or logout must stub the CLI or credential helper rather than call it.
# conftest.py
@pytest.fixture(autouse=True)
def isolated_home(tmp_path, monkeypatch):
home = tmp_path / "home"
home.mkdir()
monkeypatch.setenv("HOME", str(home))
for xdg, sub in [("CONFIG", ".config"), ("DATA", ".local/share"),
("STATE", ".local/state"), ("CACHE", ".cache")]:
monkeypatch.setenv(f"XDG_{xdg}_HOME", str(home / sub))
monkeypatch.setenv("GIT_CONFIG_GLOBAL", str(home / ".gitconfig"))
monkeypatch.setenv("GIT_CONFIG_NOSYSTEM", "1")
for var in ("GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_OBJECT_DIRECTORY",
"GIT_COMMON_DIR", "GIT_NAMESPACE", "GIT_PREFIX"):
monkeypatch.delenv(var, raising=False)
monkeypatch edits os.environ, so subprocess children inherit it. A path computed at import time (CONFIG = Path.home() / ".tool" at module level) was resolved before the fixture ran; patch that constant too, or resolve it lazily.
| Runner | Idiom |
|---|---|
| Vitest | vi.stubEnv('HOME', dir) (and the rest; vi.stubEnv(name, undefined) unsets) inside beforeEach in a setupFiles module. With unstubEnvs: true stubs are restored before every test, so a top-level stub would not persist |
| Bun | Set the variables outside the process (HOME=$(mktemp -d) bun test, or in the package.json / justfile recipe). In Bun 1.4.3, assigning process.env.HOME at runtime does not change os.homedir() or the default env of Bun.spawn; only node:child_process sees it |
| Shell | TEST_HOME=$(mktemp -d) || exit 1, then export HOME, the four XDG_*_HOME variables, GIT_CONFIG_GLOBAL and GIT_CONFIG_NOSYSTEM=1, and unset the GIT_DIR family before the first git command. The || exit 1 guards the empty-mktemp case (#1692) |
test('user registration flow', async () => {
// Arrange
const userData = { email: '[email protected]', password: 'secure123' }
const mockEmailService = vi.fn()
// Act
const user = await registerUser(userData, mockEmailService)
// Assert
expect(user).toMatchObject({ email: '[email protected]', emailVerified: false })
expect(mockEmailService).toHaveBeenCalledWith('[email protected]', expect.any(String))
})
| Context | Command |
|---|---|
| Coverage check (TS) | vitest --coverage --reporter=dot |
| Coverage check (Python) | uv run pytest --cov --cov-fail-under=80 -q |
| Find slow tests (TS) | vitest --reporter=verbose |
| Find slow tests (Python) | uv run pytest --durations=10 -q |
| Missing lines (Python) | uv run pytest --cov --cov-report=term-missing |
For detailed examples, advanced patterns, and best practices, see REFERENCE.md.
vitest-testing - TypeScript/JavaScript testingpython-testing - Python pytest testingplaywright-testing - E2E testingmutation-testing - Validate test effectivenessWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
20 skills in this plugin
/benchmark-controlsBenchmark control hazards: mutated controls, disagreeing harnesses, VM lock scaling, hyperfine 2.0 exports. Use when benchmarking, comparing timings, A/B runs, hyperfine./measurement-controlsCheck a benchmark, A/B or eval metric measures what it claims: control arms, oracles that can fail, pooled correlations, small x/N. Use when setting up an experiment or a metric says improved./mutation-testingMutation testing with Stryker (TS/JS) and mutmut (Python). Use when finding weak tests that pass on mutated code, or improving test quality through mutation analysis./odiff-image-diffingodiff pixel-by-pixel image diffing. Use when comparing screenshots, detecting visual regressions, diffing before/after PNGs, asserting golden images./playwright-cliPlaywright CLI browser automation — navigate, screenshot, fill forms, click. Use when automating browser tasks from the shell; 4-10x more token-efficient than Playwright MCP./playwright-testingPlaywright E2E testing — cross-browser, visual regression, API testing, mobile emulation. Use when writing E2E tests or setting up automated UI testing for web apps.npx claudepluginhub laurigates/claude-plugins --plugin testing-pluginOther plugins' skills for the same job