Agent skill · software engineering · github

unit-test-vue-pinia

Write and review unit tests for Vue 3 + TypeScript + Vitest + Pinia codebases. Use when creating or updating tests for components, composables, and stores; mocking Pinia with createTestingPinia; applying Vue Test Utils patterns; and enforcing black-box assertions over implementation details.

Why this skill is useful

Provides specific patterns and setups for testing Vue 3 components and Pinia stores that the AI wouldn't reliably generate on its own.

What it needs

Requires vitest installed locally. About 4k tokens when loaded. Last updated 2026-08-07. 37,534 stars on the source repository.

What this skill does

unit-test-vue-pinia Use this skill to create or review unit tests for Vue components, composables, and Pinia stores. Keep tests small, deterministic, and behavior-first. Workflow 1. Identify the behavior boundary first: component UI behavior, composable behavior, or store behavior. 2. Choose the narrowest test style that can prove that behavior. 3. Set up Pinia with the least powerful option that still covers the scenario. 4. Drive the test through public inputs such as props, form updates, button clicks, emitted child events, and store APIs. 5. Assert observable outputs and side effects before considering any instance-level assertion. 6. Return or review tests with clear behavior-oriented names and note any remaining coverage gaps. Core Rules Test one behavior per test. Assert observable input/output behavior first (rendered text, emitted events, callback calls, store state changes). Avoid implementation-coupled assertions. Access wrapper.vm only in exceptional cases when there is no reasonable DOM, prop, emit, or store-level assertion. Prefer explicit setup in beforeEach() and reset mocks every test. Use checked-in reference material in references/pinia-patterns.md as the local source of truth for standard Pinia test setups. Pinia Testing Approach Use references/pinia-patterns.md first, then fall back to Pinia's testing cookbook when the checked-in examples do not cover the case. Default pattern for component tests Use createTestingPinia as a global plugin while mounting. Prefer createSpy: vi.fn as the default for consistency and easier action-spy assertions. By default, actions are stubbed and spied. Use stubActions: true (default) when the test only needs to verify whether an action was called (or not called). Accepted minimal Pinia setups The following are also valid and should not be flagged as incorrect: createTestingPinia({}) when the test does not assert Pinia action spy behavior. createTestingPinia({ initialState: ... …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills github/unit-test-vue-pinia

View the source on GitHub

Browse the @skills marketplace