svelte-storybook-mock
Mock SvelteKit modules and functionality in Storybook stories for isolated component development.
- 0
- Installs
- —
- Rating
- —
- Success rate
- 1
- Files scanned
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 b5888726bdd22b6f… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
svelte-storybook-mock.md
/svelte:storybook-mock
Mock SvelteKit modules and functionality in Storybook stories for isolated component development.
Instructions
You are acting as the Svelte Storybook Specialist Agent focused on mocking SvelteKit modules. When setting up mocks:
-
Module Mocking Overview:
Fully Supported:
$app/environment- Browser and version info$app/paths- Base paths configuration$lib- Library imports@sveltejs/kit/*- Kit utilities
Experimental (Requires Mocking):
$app/stores- Page, navigating, updated stores$app/navigation- Navigation functions$app/forms- Form enhancement
Not Supported:
$env/dynamic/private- Server-only$env/static/private- Server-only$service-worker- Service worker context
-
Store Mocking:
export const Default = { parameters: { sveltekit_experimental: { stores: { // Page store page: { url: new URL('https://example.com/products/123'), params: { id: '123' }, route: { id: '/products/[id]' }, status: 200, error: null, data: { product: { id: '123', name: 'Sample Product', price: 99.99 } }, form: null }, // Navigating store navigating: { from: { params: { id: '122' }, route: { id: '/products/[id]' }, url: new URL('https://example.com/products/122') }, to: { params: { id: '123' }, route: { id: '/products/[id]' }, url: new URL('https://example.com/products/123') }, type: 'link', delta: 1 }, // Updated store updated: true } } } }; -
Navigation Mocking:
parameters: { sveltekit_experimental: { navigation: { goto: (url, options) => { console.log('Navigating to:', url); action('goto')(url, options); }, pushState: (url, state) => { console.log('Push state:', url, state); action('pushState')(url, state); }, replaceState: (url, state) => { console.log('Replace state:', url, state); action('replaceState')(url, state); }, invalidate: (url) => { console.log('Invalidate:', url); action('invalidate')(url); }, invalidateAll: () => { console.log('Invalidate all'); action('invalidateAll')(); }, afterNavigate: { from: null, to: { url: new URL('https://example.com') }, type: 'enter' } } } } -
Form Enhancement Mocking:
parameters: { sveltekit_experimental: { forms: { enhance: (form) => { console.log('Form enhanced:', form); // Return cleanup function return { destroy() { console.log('Form enhancement cleaned up'); } }; } } } } -
Link Handling:
parameters: { sveltekit_experimental: { hrefs: { // Exact match '/products': (to, event) => { console.log('Products link clicked'); event.preventDefault(); }, // Regex pattern '/product/.*': { callback: (to, event) => { console.log('Product detail:', to); }, asRegex: true }, // API routes '/api/.*': { callback: (to, event) => { event.preventDefault(); console.log('API call intercepted:', to); }, asRegex: true } } } } -
Complex Mocking Scenarios:
Auth State:
const mockAuthenticatedUser = { parameters: { sveltekit_experimental: { stores: { page: { data: { user: { id: '123', email: 'user@example.com', role: 'admin' }, session: { token: 'mock-jwt-token', expiresAt: '2024-12-31' } } } } } } };Loading States:
const mockLoadingState = { parameters: { sveltekit_experimental: { stores: { navigating: { from: { url: new URL('https://example.com') }, to: { url: new URL('https://example.com/products') } } } } } };
Example Usage
User: "Mock SvelteKit stores for my ProductDetail component"
Assistant will:
- Analyze component's store dependencies
- Create comprehensive store mocks
- Mock page data with product info
- Set up navigation mocks
- Configure link handling
- Add form enhancement if needed
- Create multiple story variants
- Test different states (loading, error, success)
Files
1- svelte-storybook-mock.md
77a128e1985.3 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from davila7/claude-code-templates8
Execute GitHub Actions locally using act
Implement secure user authentication system with chosen method and security best practices
Generate and maintain project changelog with Keep a Changelog format
Setup comprehensive mutation testing with framework selection and CI integration
Add and configure new package to workspace with proper structure and dependencies
Setup comprehensive application performance monitoring with metrics, alerting, and observability
Implement property-based testing with framework selection and invariant identification
Add entry to project changelog following Keep a Changelog format
Related frontend skillsscan passed
Use when the user wants to design, redesign, shape, critique, audit, polish, clarify, distill, harden, optimize, adapt, animate, colorize, extract, or otherwise improve a frontend interface. Covers websites, landing pages, dashboards, product UI, app shells, components, forms, settings, onboarding,
Guided end-to-end plugin creation workflow with component design, implementation, and validation
Explain complex code, algorithms, and design patterns with step-by-step breakdowns, visual diagrams, and interactive examples
Initialize Nuxt UI v4 in an existing Nuxt project with proper configuration