svelte-testing
Svelte Testing
Quick Start
// Client-side component test (.svelte.test.ts)
import { render } from 'vitest-browser-svelte';
import { expect } from 'vitest';
import Button from './button.svelte';
test('button click increments counter', async () => {
const { page } = render(Button);
const button = page.getByRole('button', { name: /click me/i });
await button.click();
await expect.element(button).toHaveTextContent('Clicked: 1');
});
Core Principles
- Always use locators:
page.getBy*()methods, never containers - Multiple elements: Use
.first(),.nth(),.last()to avoid strict mode violations - Use untrack(): When accessing
$derivedvalues in tests - Real API objects: Test with FormData/Request, minimal mocking
Reference Files
- core-principles | foundation-first | client-examples
- server-ssr-examples | critical-patterns
- client-server-alignment | troubleshooting
Notes
- Never click SvelteKit form submit buttons - Always use
await expect.element() - Test files:
.svelte.test.ts(client),.ssr.test.ts(SSR),server.test.ts(API)
More from linehaul-ai/linehaulai-claude-marketplace
geospatial-postgis-patterns
Implement geofences, spatial queries, real-time tracking, and mapping features in laneweaverTMS using PostGIS and PGRouting. Use when building location-based features, distance calculations, ETA predictions, or fleet visualization.
83quickbooks-online-api
Expert guide for QuickBooks Online API integration covering authentication, CRUD operations, batch processing, and best practices for invoicing, payments, and customer management.
61rbac-authorization-patterns
Provide patterns for implementing Role-Based Access Control and multi-tenant authorization in laneweaverTMS. Use when implementing user roles, permissions, tenant isolation, Echo authorization middleware, RLS policies for multi-tenant access, or JWT claims structure for freight brokerage applications.
61slack-block-kit
Build Slack Block Kit UIs for messages, modals, and Home tabs. Use when creating Slack notifications, interactive forms, bot responses, app dashboards, or any Slack UI. Covers blocks (Section, Actions, Input, Header), elements (Buttons, Selects, Date pickers), composition objects, and the slack-block-builder library.
44svelte-flow
Build node-based editors, interactive diagrams, and flow visualizations using Svelte Flow. Use when creating workflow editors, data flow diagrams, organizational charts, mindmaps, process visualizations, DAG editors, or any interactive node-graph UI. Supports custom nodes/edges, layouts (dagre, hierarchical), animations, and advanced features like proximity connect, floating edges, and contextual zoom.
35testcontainers-go
Use this skill when writing Go integration tests with Docker containers, using testcontainers-go modules (postgres, redis, kafka, etc.), setting up container-based test infrastructure, or configuring container networking and wait strategies. Covers 62+ pre-configured modules, cleanup patterns, and multi-container setups.
34