svelte-test-setup — Claude Code command: test setup
Set up test infrastructure for Svelte and SvelteKit, with Vitest for unit and component checks and Playwright for end-to-end tests.
npx claude-code-templates@latest --command svelte/svelte-test-setupWhat svelte-test-setup does
The command inspects the project structure, existing test tools, and scripts in package.json before changing the setup. It can configure Vitest for unit and component tests, then add Playwright for end-to-end coverage. Helpers, fixtures, and sample tests can be part of the resulting setup.
The Vitest configuration uses jsdom, a src/tests/setup.ts file, and coverage reporters. Playwright gets its own configuration, fixtures, and page object models. Optional additions include API mocking and visual regression tools. What gets added depends on the project’s current setup. With jsdom configured, tests run in that environment; it does not itself check behavior in a browser.
What it helps with
- configure Vitest in a SvelteKit project
- add component tests with Testing Library
- set up Playwright end-to-end tests
- organize test helpers and fixtures
- add npm scripts for tests and coverage reports
Example prompts for the agent
- Set up testing for my SvelteKit project.
- Add Vitest and component tests to this Svelte app.
- Configure Playwright end-to-end tests and scripts to run them.
How to install svelte-test-setup
1claude-code-templates
npx claude-code-templates@latest --command svelte/svelte-test-setup2Manually: put the files in place
.claude/commands/svelte-test-setup.mdCall it with /svelte-test-setup. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/svelte-test-setup.mdCall it with /prompts:svelte-test-setup. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/svelte-test-setup.prompt.mdManually: put the files in place
.gemini/commands/svelte-test-setup.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about svelte-test-setup
How do I install svelte-test-setup in Claude Code?
Run npx claude-code-templates@latest --command svelte/svelte-test-setup to install the command for Claude Code.
What does svelte-test-setup do?
It reviews the project’s existing test setup, then helps configure Vitest and Playwright. It can also create config files, test examples, and npm scripts.
Which testing tools does svelte-test-setup configure?
It uses Vitest for unit and component tests, with @testing-library/svelte available for component testing. Playwright handles end-to-end tests.
Source text
svelte-test-setup.md · MIT
---
description: "Set up comprehensive testing infrastructure for Svelte/SvelteKit projects, including unit testing, component testing, and E2E testing frameworks."
---
# /svelte:test-setup
Set up comprehensive testing infrastructure for Svelte/SvelteKit projects, including unit testing, component testing, and E2E testing frameworks.
## Instructions
You are acting as the Svelte Testing Specialist Agent focused on testing infrastructure. When setting up testing:
1. **Assess Current State**:
- Check existing test setup
- Identify missing testing tools
- Review package.json for test scripts
- Analyze project structure
2. **Testing Stack Setup**:
**Unit/Component Testing (Vitest)**:
- Install dependencies: `vitest`, `@testing-library/svelte`, `jsdom`
- Configure vitest.config.js
- Set up test helpers and utilities
- Create setup files
**E2E Testing (Playwright)**:
- Install Playwright
- Configure playwright.config.js
- Set up test fixtures
- Create page object models
**Additional Tools**:
- Coverage reporting (c8/istanbul)
- Test utilities (@testing-library/user-event)
- Mock service worker for API mocking
- Visual regression testing tools
3. **Configuration Files**:
```javascript
// vitest.config.js
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';
export default defineConfig({
plugins: [sveltekit()],
test: {
environment: 'jsdom',
setupFiles: ['./src/tests/setup.ts'],
coverage: {
reporter: ['text', 'html', 'lcov']
}
}
});
```
4. **Test Structure**:
```
src/
├── tests/
│ ├── setup.ts
│ ├── helpers/
│ └── fixtures/
├── routes/
│ └── +page.test.ts
└── lib/
└── Component.test.ts
```
5. **NPM Scripts**:
- `test`: Run all tests
- `test:unit`: Run unit tests
- `test:e2e`: Run E2E tests
- `test:coverage`: Generate coverage report
- `test:watch`: Run tests in watch mode
## Example Usage
User: "Set up testing for my new SvelteKit project"
Assistant will:
- Analyze current project setup
- Install and configure Vitest
- Install and configure Playwright
- Create test configuration files
- Set up test utilities and helpers
- Add comprehensive npm scripts
- Create example tests
- Set up CI/CD test workflows
© davila7 · MIT · davila7/claude-code-templates