WesleySmits/agent-skills / .agent/skills/vue-component-architect
scaffolding-vue-components
VerifiedScaffolds Vue/Nuxt components with Composition API, CSS modules, Vitest tests, and Storybook stories. Use when the user asks to create a Vue component, generate component boilerplate, or mentions Vue 3 architecture.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 5.6 KB |
| examples/advanced-patterns.md | markdown | 3.9 KB |
| examples/component-templates.md | markdown | 3.6 KB |
| examples/storybook.md | markdown | 3.5 KB |
| examples/testing.md | markdown | 3.2 KB |
examples/testing.md
View on GitHub# Vue Testing Examples
## Vitest with Vue Test Utils
```typescript
import { describe, it, expect, vi } from "vitest";
import { mount } from "@vue/test-utils";
import ComponentName from "./ComponentName.vue";
describe("ComponentName", () => {
it("renders slot content", () => {
const wrapper = mount(ComponentName, {
slots: {
default: "Hello",
},
});
expect(wrapper.text()).toContain("Hello");
});
it("renders label prop", () => {
const wrapper = mount(ComponentName, {
props: {
label: "Click me",
},
});
expect(wrapper.text()).toContain("Click me");
});
it("applies variant class", () => {
const wrapper = mount(ComponentName, {
props: {
variant: "secondary",
},
});
expect(wrapper.classes()).toContain(expect.stringContaining("secondary"));
});
it("emits click when not disabled", async () => {
const wrapper = mount(ComponentName);
await wrapper.trigger("click");
expect(wrapper.emitted("click")).toHaveLength(1);
});
it("does not emit click when disabled", async () => {
const wrapper = mount(ComponentName, {
props: {
disabled: true,
},
});
await wrapper.trigger("click");
expect(wrapper.emitted("click")).toBeUndefined();
});
it("sets disabled attribute", () => {
const wrapper = mount(ComponentName, {
props: {
disabled: true,
},
});
expect(wrapper.attributes("disabled")).toBeDefined();
});
});
```
## Testing with Pinia
```typescript
import { describe, it, expect, beforeEach } from "vitest";
import { mount } from "@vue/test-utils";
import { createPinia, setActivePinia } from "pinia";
import ComponentName from "./ComponentName.vue";
describe("ComponentName", () => {
beforeEach(() => {
setActivePinia(createPinia());
});
it("renders with store state", () => {
const wrapper = mount(ComponentName);
expect(wrapper.exists()).toBe(true);
});
});
```
## Testing Composables
```typescript
import { describe, it, expect } from "vitest";
import { useComponentLogic } from "./useComponentLogic";
describe("useComponentLogic", () => {
it("initializes with value", () => {
const { value } = useComponentLogic("initial");
expect(value.value).toBe("initial");
});
it("updates value and calls onChange", () => {
const onChange = vi.fn();
const { value, updateValue } = useComponentLogic("", onChange);
updateValue("new value");
expect(value.value).toBe("new value");
expect(onChange).toHaveBeenCalledWith("new value");
});
});
```
## Testing Async Components
```typescript
import { describe, it, expect, vi } from "vitest";
import { mount, flushPromises } from "@vue/test-utils";
import AsyncComponent from "./AsyncComponent.vue";
// Mock the API
vi.mock("@/api", () => ({
fetchData: vi.fn().mockResolvedValue({ items: ["a", "b"] }),
}));
describe("AsyncComponent", () => {
it("loads and displays data", async () => {
const wrapper = mount(AsyncComponent);
// Initially shows loading
expect(wrapper.text()).toContain("Loading");
// Wait for async operations
await flushPromises();
// Now shows data
expect(wrapper.text()).toContain("a");
expect(wrapper.text()).toContain("b");
});
});
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate 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 existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |