/saas-builder:saas-testingfrom saas-builder
Set up a testing strategy for a SaaS application. Unit tests with Vitest, E2E tests with Playwright, API route testing, webhook mocking, Stripe test mode, and CI integration. Use this skill when the user wants anything related to testing, writing tests, E2E, unit tests, Playwright, Vitest, coverage, or quality assurance. Phrases like "write tests", "set up testing", "add E2E", "run tests in CI" trigger this skill.
Ships in saas-builder. 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.
None: SKILL.md is the whole skill.
This skill sets up the testing infrastructure for a SaaS application. Without tests, claiming "production-ready" is incomplete — you can only guarantee that the payment webhook works, the auth flow hasn't broken, and the API behaves as expected through tests.
Dependency: This skill is the pre-deployment quality assurance step of the saas-launcher orchestrator skill. It can also be used independently.
Related skills:
Unit Test — Vitest: Tests individual functions and utilities. Runs fast, no external dependencies. Uses: price calculation, plan checking, input validation, helper functions.
Integration Test — Vitest: Tests API routes. Sends HTTP requests, validates responses. Uses: auth endpoints, checkout API, webhook handler.
End-to-End Test (E2E) — Playwright: Tests user flows in a real browser. Slowest but most reliable. Uses: sign up → log in → purchase plan → access dashboard.
Don't try to test everything on Day 1. Priority order:
A modern test runner, alternative to Jest. Advantages: Vite-based — very fast, native ESM support, Jest-compatible API (easy migration), built-in TypeScript support, watch mode with HMR.
npm install -D vitest @vitejs/plugin-react
Create vitest.config.ts at the project root. Use a __tests__/ folder for test files or the .test.ts / .spec.ts extension in the filename.
Add scripts to package.json:
"test": "vitest run" — run once"test:watch": "vitest" — watch mode"test:coverage": "vitest run --coverage" — coverage reportTo test Next.js API routes, directly import the route handler function and call it with a mock Request object. No need to spin up a real HTTP server.
Each test:
Webhook tests are the most critical tests. Testing strategy:
checkout.session.completed → user plan should become "pro".Stripe test mode: Forward webhooks to localhost with Stripe CLI:
stripe listen --forward-to localhost:3000/api/stripe/webhook
stripe trigger checkout.session.completed
Mock external services, don't mock your own code:
Module-level mocking with Vitest's vi.mock() function:
A modern E2E testing tool, alternative to Cypress. Advantages: multi-browser support (Chromium, Firefox, WebKit), auto-wait, debugging with trace viewer, headless CI mode.
npm install -D @playwright/test
npx playwright install
Create playwright.config.ts. Basic settings:
baseURL: http://localhost:3000webServer: automatically start the dev server before testsuse.trace: on-first-retry — record trace only for failing testsAuth flow:
Checkout flow:
Landing page:
page.getByRole(), page.getByText(), page.getByTestId() — CSS selectors are brittle.waitForTimeout() — Playwright automatically waits for elements to appear.Add test steps to the CI pipeline:
vitest run — should run on every PRnpx playwright test — on every PR or only before main mergePlaywright runs in headless mode in CI. Install browser dependencies with playwright install --with-deps in GitHub Actions. Save failing test traces as artifacts — download and open with npx playwright show-trace for debugging.
Don't aim for 100% overall coverage. Writing meaningless tests is just as bad as not writing tests. Protect critical paths with high coverage; keep the rest pragmatic.
waitForTimeout()..env.test file or CI secrets for the test environment. Production keys must not be in CI.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub carriegale2710/skills-library --plugin saas-builder12 skills in this plugin
/saas-analyticsSet up PostHog analytics and product analysis for a SaaS application. Event tracking, user identification, feature flags, session replay, funnel analysis, and privacy-compliant configuration. Use this skill when the user wants anything related to user analytics, PostHog, event tracking, user behaviour, feature flags, A/B testing, conversion analysis, or metric tracking. Phrases like "set up analytics", "track users", "add PostHog", "create a feature flag" trigger this skill.
/saas-api-securitySet up an API security layer for a SaaS application. Rate limiting, plan-based access control, input validation, error handling, CORS, and health checks. Use this skill when the user wants anything related to API security, rate limiting, authorisation, input validation, error handling, or API protection. Phrases like "secure the API", "add rate limiting", "check the plan", "input validation" trigger this skill.
/saas-authSet up the authentication layer of a SaaS application. Covers Google OAuth, Magic Link, email/password login, JWT session management, and middleware for protected routes. Use this skill when the user wants to add authentication, set up login, or configure user sessions.
Other plugins' skills for the same job