All skills
paulrberg avatar

/vitest

@56b7c32
by Paul Bergpaulrberg/agent-skills94 stars
7

Use for Vitest in TypeScript projects (Node, bun, React/Next.js, Effect): write, run, or debug unit/component tests, mocks, testing utilities, and coverage.

Use this Skill: https://skilld.dev/gh/paulrberg/agent-skills/vitest

This session only. Nothing lands on disk.

referencesmocking.md

≈336 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Mocking

Mock boundaries and own their cleanup; prefer dependency injection when it keeps the production interface simpler.

  • vi.mock is hoisted. Keep it at file scope (v5 throws otherwise); put handles used by its factory in vi.hoisted. Its specifier must be identical to the production import specifier, and it cannot mock require().
  • Create a fresh result from every stateful mock factory per test. Keep one-off module wiring in that file; share only repository-conventional factories.
  • Install fake timers before code schedules work. Use async advancement when callbacks schedule promises, and always restore real timers. Do not combine fake timers with uncontrolled real waits. From v5, fake timers and vi.setSystemTime also mock a global Temporal.
  • From v5, clearMocks defaults to true: call history is cleared before each test, so assert on calls made inside that test unless the repository sets clearMocks: false.
  • Restore owned spies, timers, environment stubs, and replaced global property descriptors in local cleanup. vi.restoreAllMocks() restores vi.spyOn implementations but neither clears their history nor restores automocks; reset or reconfigure automocked exports explicitly.

See the installed version's Vi API for factory, timer, and stub semantics.

Source: SKILL.md on GitHub

No alertstoday3 checks · Risk SAFE
  • Gen Agent Trust Hubtoday

    The skill provides comprehensive instructions for Vitest testing workflows, including configuration, mocking, and troubleshooting. It uses standard developer tools and refers to official Vitest documentation. A minor risk exists regarding indirect prompt injection, as the skill executes code from the repository it operates on, which is typical for development-oriented agents.

  • Sockettoday

    No alerts

  • Snyktoday

    Risk: LOW · No issues

Signed by skilld at 56b7c32. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 2 weeks ago

README badge

README badge for paulrberg/agent-skills/vitest