skills/cleanexpo/testing-patterns/SKILL.md
Vitest testing patterns and strategies for unit tests, agent tests, and API tests with Supabase mocking
npx skillsauth add aiskillstore/marketplace testing-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
When to Use: Writing tests for new features, agents, API routes
Command: npm run test
Required: 100% pass rate
Location: tests/ directory
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { MyService } from '@/lib/services/my-service';
describe('MyService', () => {
let service: MyService;
beforeEach(() => {
vi.clearAllMocks();
service = new MyService();
});
it('should process data correctly', () => {
const input = { value: 42 };
const result = service.process(input);
expect(result).toBeDefined();
expect(result.value).toBe(42);
});
it('should handle errors', () => {
expect(() => service.process(null)).toThrow();
});
});
import { describe, it, expect, vi } from 'vitest';
import { MyAgent } from '@/lib/agents/my-agent';
// Mock Supabase
vi.mock('@supabase/supabase-js', () => ({
createClient: vi.fn(() => ({
from: vi.fn(() => ({
select: vi.fn().mockReturnThis(),
eq: vi.fn().mockResolvedValue({ data: [], error: null })
}))
}))
}));
describe('MyAgent', () => {
it('processes task successfully', async () => {
const agent = new MyAgent();
const task = {
id: 'test-1',
workspace_id: 'ws-123',
task_type: 'test',
payload: {},
priority: 5,
retry_count: 0,
max_retries: 3
};
const result = await agent.processTask(task);
expect(result).toBeDefined();
});
});
import { describe, it, expect } from 'vitest';
import { GET } from '@/app/api/my-endpoint/route';
import { NextRequest } from 'next/server';
describe('GET /api/my-endpoint', () => {
it('requires workspace_id', async () => {
const req = new NextRequest('http://localhost:3008/api/my-endpoint');
const response = await GET(req);
const data = await response.json();
expect(response.status).toBe(400);
expect(data.error).toContain('workspaceId required');
});
});
const mockSelect = vi.fn().mockReturnThis();
const mockEq = vi.fn().mockReturnThis();
const mockInsert = vi.fn().mockReturnThis();
const mockFrom = vi.fn(() => ({
select: mockSelect,
eq: mockEq,
insert: mockInsert
}));
vi.mock('@supabase/supabase-js', () => ({
createClient: vi.fn(() => ({
from: mockFrom
}))
}));
// Set return values
mockEq.mockResolvedValue({ data: [{ id: '1', name: 'Test' }], error: null });
Target: 100% pass rate (no failures allowed)
Standard: All code must have tests, all tests must pass
development
Apple Human Interface Guidelines for content display components. Use this skill when the user asks about charts component, collection view, image view, web view, color well, image well, activity view, lockup, data visualization, content display, displaying images, rendering web content, color pickers, or presenting collections of items in Apple apps. Also use when the user says how should I display charts, what's the best way to show images, should I use a web view, how do I build a grid of items, what component shows media, or how do I present a share sheet. Cross-references: hig-foundations for color/typography/accessibility, hig-patterns for data visualization patterns, hig-components-layout for structural containers, hig-platforms for platform-specific component behavior.
tools
Automate HelpDesk tasks via Rube MCP (Composio): list tickets, manage views, use canned responses, and configure custom fields. Always search tools first for current schemas.
testing
Expert Haskell engineer specializing in advanced type systems, pure functional design, and high-reliability software. Use PROACTIVELY for type-level programming, concurrency, and architecture guidance.
tools
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.