Source: https://www.hype-stack.dev/docs/development/testing

# Testing

The template uses Vitest on both sides. Tests sit next to the code they cover. The goal is confidence in your features,
not snapshots of framework behavior.

## Backend

Backend tests live under `apps/backend` next to features and routes. They run against a real Postgres from
`apps/backend/docker-compose.test.yml`, on its own port so it never collides with your dev database. `create` prepares
it when you say yes to migrations; otherwise run it once yourself:

```bash
pnpm --filter @hype-stack/backend test:setup
```

Prefer integration-style tests that hit real modules and that database over mocking the query layer.

Conventions from the repo rules:

- Throw typed errors; do not assert on swallowed `try/catch` paths that the error middleware would handle
- Keep mutations and queries tested through the feature modules when practical
- Use the shared testing helpers under `apps/backend/src/testing/`

Run:

```bash
pnpm --filter @hype-stack/backend test
```

## Frontend

Frontend tests use Testing Library and HyperFetch `setMock` on SDK requests. That keeps hooks and components real while
controlling the network boundary.

```bash
pnpm --filter @hype-stack/frontend test
```

Do not mock `@hyper-fetch/react`, the router, or internal hooks unless there is no other way. Prefer `setMock` on
`sdk.*` requests and clean mocks in `afterEach`.

## Mobile

Mobile tests use Vitest with `vitest-native` and Testing Library for React Native.

```bash
pnpm --filter @hype-stack/mobile test
```

To run the app on a phone or simulator, see [Mobile](/docs/mobile).

## Playwright / E2E

Browser E2E coverage depends on what your project generated and which packs you installed. If Playwright is present in
the workspace, treat auth, org onboarding, and billing checkout as the high-value paths. Pack and registry sandboxes
also exercise combinations outside your app; that is for pack authors, not day-to-day app work.

## What not to test

- Pure re-exports and config objects
- Framework behavior (Hono routing, React rendering with no assertions)
- Third-party dashboard UIs (Stripe Checkout, WorkOS hosted screens)

## Related

- [E2E typesafety](/docs/development/e2e-typesafety)
- [Mobile](/docs/mobile)
- [Commands](/docs/development/commands)
