/svelte-5:vitestfrom svelte-5
Configures Vitest test.projects, browser mode with Playwright, optimizeDeps, and separate vitest.config from vite.config. Helps debug flaky browser tests, upgrade @vitest/* packages, and split node vs browser project configs.
Ships in svelte-5. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
https://vitest.dev/llms.txt. Do not guessvitest.config.{ts,mts,js,mjs} for test / test.projects. Vitest-only-in-vite.config merges badly with multiple projects and Storybookvitest.config.* but vite.config has test: (or no Vitest file), ask before adding projects or Storybook whether to introduce vitest.config.ts and move test out of Vitetest.projects get the root's plugins, resolve, optimizeDeps, and setupFiles; extends: false opts out. NEVER repeat an inherited root plugin inside a project: a second svelte() compiles components twice. Inheritance rules, sharedViteServer, tags: references/config-projects.md@vitest/* together. Vitest 4 to 5 breaking changes, post-upgrade cleanup, and 5.0 to 5.1 changes: references/vitest-5-upgrade.mdbrowser.provider: import { playwright } from '@vitest/browser-playwright' to provider: playwright() (factory, not a string). Use import { page } from 'vitest/browser': not @vitest/browser/contextrune_outside_svelte: a rune "is only available inside .svelte and .svelte.js/ts files"; in browser mode, until the page has loaded Svelte's client runtime (a component, vitest-browser-svelte or an import from svelte itself, e.g. tick), a $state call shows ReferenceError: $state is not defined instead (the form in a node project is not covered here). Cause: the rune sits in a .js/.ts file without the .svelte. infix (foo.svelte.ts and foo.svelte.test.ts have it); rename it, update its imports, and for a test file check which project's include and exclude the new name matches. On Vite 8, a dependency's file must end in .svelte.js/.svelte.ts; report one that does not to the library. More in svelte-5:testing-svelte troubleshootingoptimizeDeps.exclude does not fix rune_outside_svelte on Vite 8: the file name decides whether vite-plugin-svelte compiles the runes, pre-bundled or not (pre-bundling uses Rolldown since Vite 8, esbuild before)optimizeDeps.include: deps that trigger mid-test optimization (e.g. minisearch) to reduce flakes; once you list one msw entry point, list every one you import, or narrow frames with frame.protocol (svelte-5:msw). Symptoms, fixes and optimizeDeps.entries: references/flake-hygiene.mdvitest.config.ts + storybookTest + browser playwright(): svelte-5:storybook-vitest, manual setuptest.outputFile (reporter options beat the CLI; the HTML reporter takes outputDir); coverage thresholds take flat metric keys, a Jest-style global key enforces nothing: references/config-projects.mdtoBeInTheDocument on a role-only or loose locator, not.toBe(''), toHaveBeenCalled) ship regressions; toBeInTheDocument on an exact-text locator checks a value. Every interaction test must compute an expected value from the action and assert equality. See references/assertions.md for the pattern, callback-payload rules, and how to tell a harness failure from a behavior failuretoHaveTextContent is exact (Vitest 5): full-string equality, no RegExp. toHaveTextContent('Error') fails on Error!. Partial or regex matches use toMatchTextContent, a weaker check: prefer the exact computed string when you can build it. In a Storybook play function, expect from storybook/test has jest-dom's toHaveTextContent, which matches substrings and RegExp: svelte-5:storybook-vitestpage.getByText('Hello') does not find Hello, World. Use the full text, a RegExp, or { exact: false }: references/browser-mode.mdpage.getByRole(...), getByLabelText, getByText, getByPlaceholder, getByTitle, getByAltText first. They mirror how screen readers find elements and fail when a11y regresses. data-testid is an a11y smell (tkdodo, 2025): a testid means the element has no accessible name, role, or text for users of AT either. Fix the a11y hole, not the test. Reach for data-testid, a raw querySelector, or a test-id output div in a fixture only as a last resort: charting canvases, decorative content, third-party widgets without roles, an overlay that intercepts clicks on the real control, legacy markup you cannot change. Each use gets a one-line comment explaining why no accessible selector workedvitest-browser-svelte v3: render is async-only (await render(...)); usage in svelte-5:testing-svelte. The main entry cleans up in beforeEach; /pure never cleans up. Don't use it.concurrent for browser component tests: expect.element breaks there: references/browser-mode.mdpage.viewport(width, height) from vitest/browser for desktop layoutsvi.mock / vi.hoisted at the top level only; reference module-level fakes in a factory via vi.hoisted or a top-level await import(); mock SvelteKit's $app/* in browser tests; import-map mocking errors and fake timers: references/mocking.mdawait expect.element(locator) for locators, expect.poll(() => value) or vi.waitFor for spies and other state (references/browser-mode.md). Negative assertions need a positive precondition and a settle window (references/flake-hygiene.md)toMatchScreenshot(); baselines are platform-specific, so decide where they are generated before committing any: references/visual-regression.mdBrowser and Storybook suites are flaky on a single run. Kill a test-server port holder left over from an earlier run of this suite (never another project's live run), clear node_modules/.vite and node_modules/.cache/storybook, then run three times: counts must match within ±0 tests and setup time within ±30%. A --last-failed or --since-last-run run is not one of the three. If runs diverge, investigate the flake BEFORE claiming any fix works. Full protocol and flake patterns: references/flake-hygiene.md.
references/assertions.md (opens in a new tab)references/browser-mode.md (opens in a new tab)references/config-projects.md (opens in a new tab)references/flake-hygiene.md (opens in a new tab)references/mocking.md (opens in a new tab)references/visual-regression.md (opens in a new tab)references/vitest-5-upgrade.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
8 skills in this plugin
/code-style-svelteSvelte component code style rules. Auto-invoke when creating .svelte files, editing component structure, transitions or layout reads, or SvelteKit URL state and navigation guards. Covers component docs and Svelte style conventions./composition-svelteUse when composing a Svelte 5 feature from provider/wrapper components, content snippets, reactive state, or third-party DOM bridging (maplibre, leaflet, d3, tippy, popper). Covers overlay wrappers, snippet APIs, and state location./doc-componentDocument a Svelte component using @component JSDoc. Auto-invoke when asked to document a .svelte component. Reads the component, analyzes its interface, and writes a structured @component comment block./mswMocks HTTP with msw 3 in Svelte, Storybook, Vitest and SvelteKit. Use when writing http.get handlers or parameters.msw, upgrading from msw 2, or debugging blank stories, handler order, query strings, onUnhandledFrame or mockServiceWorker.js./storybookStorybook authoring and browser checks for Svelte: MCP instructions, previews, Svelte 4 store wrappers, CSS imports in preview.ts. Use when writing or reviewing .stories.svelte files, moving a CSS import that stories need, or a story renders empty./storybook-vitestSvelte CSF stories as Vitest browser tests via @storybook/addon-vitest: play, tags, decorators, asChild. Use when wiring or debugging them in Vitest/CI, or on 'Vitest failed to find the current suite' or props_invalid_value. Not for React/Vue.npx claudepluginhub fubits1/svelte-skills --plugin svelte-5Other plugins' skills for the same job