ignitionstack.pro v1.0 is out! Read the announcement →
Skip to Content

Testing

Overview of the ignitionstack.pro quality gates. Tests are divided into unit, integration, and end-to-end layers so we can validate UI, business rules, and real browser flows without duplicating effort.

Test Stack

TypeToolingPurpose
Unit & Integrationvitest + happy-dom + @testing-library/reactFast feedback for components, hooks, repositories, actions
Coverage@vitest/coverage-v8V8 coverage reports (./coverage)
Helperssrc/app/test/setup.tsx, src/app/test/utils/*Global mocks (Next.js, next-intl) and factories
End-to-End@playwright/test + playwright.config.tsFull browser journeys with fixtures, auth setup, visual regression aids

The Vitest config (vitest.config.ts) wires absolute imports (@/), loads .env.test, and points to src/app/test/setup.tsx. Playwright uses playwright.config.ts with base URL http://127.0.0.1:3100, per-project auth setup, HTML reports, and the shared output folder playwright-report/.

Test Layers

LayerLocationValidatesTypical Command
Unitsrc/app/test/unit/**/*.test.ts[x]Pure functions, hooks, UI primitivesvitest run src/app/test/unit/components --runInBand
Integrationsrc/app/test/integration/**/*Server actions, repositories, API handlers, webhooksvitest run src/app/test/integration/actions
End-to-Endsrc/app/test/e2e/{tests,pages,fixtures}Real browser UX (navigation, auth, a11y)npm run e2e (Playwright)

Unit Tests

Example snippet

import { render, screen } from '@testing-library/react'; import { PricingCard } from '@/app/components/pricing-card'; test('renders CTA label', () => { render(<PricingCard plan="pro" />); expect(screen.getByRole('button', { name: /buy now/i })).toBeVisible(); });

Integration Tests

End-to-End Tests

E2E Setup Checklist

  1. npx playwright install --with-deps (once per machine/CI agent).
  2. Ensure .env.local (or the CI env) contains the same keys the app needs in dev.
  3. Run npm run e2e to execute the suite. Use npm run dev:e2e separately when you want to keep the dev server alive while iterating with npx playwright test --ui.

Utilities & Helpers

FilePurpose
src/app/test/setup.tsxLoads .env.test, clears mocks, and stubs Next.js globals before every Vitest run
src/app/test/utils/test-factories.tsFactory functions for posts, products, projects, insights…
src/app/test/utils/supabase-mock.tsChainable mocks for Supabase from().select().eq() flows
src/app/test/e2e/pages/*Page objects (homePage, blogPage, etc.) containing visit + assert helpers
scripts/test-build.shSmoke build executed via npm run build:test before CI e2e runs

Available Scripts

# Vitest layers npm test # unit + integration npm run test:watch # watch mode npm run test:ui # Vitest UI npm run test:coverage # coverage via v8 # Playwright npm run dev:e2e # Start the dedicated Next.js server locally npm run e2e # headless npm run e2e:headed # headed npm run e2e:ui # GUI to pick tests npm run e2e:debug # debugger npm run e2e:report # show last report

Best Practices

Pre-PR Checklist

Useful Resources

Keep this page updated whenever you add utilities, commands, or best practices so the team always has a single source of truth.