svelte-testing

// Client-side component test (.svelte.test.ts) import { render } from 'vitest-browser-svelte'; import { expect } from 'vitest'; import Button from './button.svelte';

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "svelte-testing" with this command: npx skills add linehaul-ai/linehaulai-claude-marketplace/linehaul-ai-linehaulai-claude-marketplace-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 $derived values 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)

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

slack-client-fundamentals

No summary provided by upstream source.

Repository SourceNeeds Review
General

geospatial-postgis-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
General

rbac-authorization-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
General

quickbooks-online-api

No summary provided by upstream source.

Repository SourceNeeds Review