From Napkin
Creates and reviews unit tests for Vue 3 + TypeScript + Vitest + Pinia codebases. Covers components, composables, and stores with createTestingPinia and Vue Test Utils.
How this skill is triggered — by the user, by Claude, or both
Slash command
/napkin:unit-test-vue-piniaThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Use this skill to create or review unit tests for Vue components, composables, and Pinia stores. Keep tests small, deterministic, and behavior-first.
Use this skill to create or review unit tests for Vue components, composables, and Pinia stores. Keep tests small, deterministic, and behavior-first.
wrapper.vm only in exceptional cases when there is no reasonable DOM, prop, emit, or store-level assertion.beforeEach() and reset mocks every test.references/pinia-patterns.md as the local source of truth for standard Pinia test setups.Use references/pinia-patterns.md first, then fall back to Pinia's testing cookbook when the checked-in examples do not cover the case.
Use createTestingPinia as a global plugin while mounting.
Prefer createSpy: vi.fn as the default for consistency and easier action-spy assertions.
const wrapper = mount(ComponentUnderTest, {
global: {
plugins: [
createTestingPinia({
createSpy: vi.fn,
}),
],
},
});
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).
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: ... }) or createTestingPinia({ stubActions: ... }) without createSpy, when the test only needs state seeding or action stubbing behavior and does not inspect generated spies.setActivePinia(createTestingPinia(...)) in store/composable-focused tests (without mounting a component) when mocking/seeding dependent stores is needed.Use createSpy: vi.fn when action spy assertions are part of the test intent.
Use stubActions: false only when the test must validate the action's real behavior and side effects. Do not switch it on by default for simple "was called" assertions.
const wrapper = mount(ComponentUnderTest, {
global: {
plugins: [
createTestingPinia({
createSpy: vi.fn,
stubActions: false,
}),
],
},
});
initialStateconst wrapper = mount(ComponentUnderTest, {
global: {
plugins: [
createTestingPinia({
createSpy: vi.fn,
initialState: {
counter: { n: 20 },
user: { name: "Leia Organa" },
},
}),
],
},
});
createTestingPiniaconst wrapper = mount(ComponentUnderTest, {
global: {
plugins: [
createTestingPinia({
createSpy: vi.fn,
plugins: [myPiniaPlugin],
}),
],
},
});
const pinia = createTestingPinia({ createSpy: vi.fn });
const store = useCounterStore(pinia);
store.double = 999;
// @ts-expect-error test-only reset of overridden getter
store.double = undefined;
Prefer pure store tests with createPinia() when the goal is to validate store state transitions and action behavior without component rendering. Use createTestingPinia() only when you need stubbed dependent stores, seeded test doubles, or action spies.
beforeEach(() => {
setActivePinia(createPinia());
});
it("increments", () => {
const counter = useCounterStore();
counter.increment();
expect(counter.n).toBe(1);
});
Follow Vue Test Utils guidance: https://test-utils.vuejs.org/guide/
findComponent(...).vm.$emit(...) for child stub events instead of touching parent internals.nextTick only when updates are async.wrapper.emitted(...).wrapper.vm only when no DOM assertion, emitted event assertion, prop assertion, or store-level assertion can express the behavior. Treat it as an exception and keep the assertion narrowly scoped.Emit and assert payload:
await wrapper.find("button").trigger("click");
expect(wrapper.emitted("submit")?.[0]?.[0]).toBe("Mango Mission");
Update input and assert output:
await wrapper.find("input").setValue("Agent Violet");
await wrapper.find("form").trigger("submit");
expect(wrapper.emitted("save")?.[0]?.[0]).toBe("Agent Violet");
create or update, return the finished test code plus a short note describing the selected Pinia strategy.review, return concrete findings first, then missing coverage or brittleness risks.references/pinia-patterns.mdnpx claudepluginhub ani1797/forge --plugin copilot-sdk3plugins reuse this skill
First indexed Jun 6, 2026
Tests Vue 3 SPAs with Vitest, @vue/test-utils, Pinia mocking, composable testing, msw, Cypress, and Playwright.
Reviews Vue 3 testing patterns with Vitest and Vue Test Utils for components, composables, Pinia stores, Vue Router, async/Suspense, Teleport, forms, accessibility, and Playwright E2E strategy. Advisory only.
Guides authoring and reviewing frontend unit, component, and lightweight integration tests using React Testing Library, Vue Test Utils, accessible queries, user-event interactions, and controlled mocks.