Testing
Running the backend and Storybook tests yourself, and where to add a test.
Run it locally
| Command | What it runs |
|---|---|
yarn test | The backend suite |
yarn storybook:test | Storybook play tests. Start Storybook first |
yarn lint | oxlint and syncpack |
yarn format | Prettier, as a check. yarn format:fix writes |
yarn a11y | The accessibility sweep. See Accessibility |
yarn security:semgrep | The Semgrep rules. See Security |
Backend tests
The backend suite runs against a real Postgres, started fresh by Testcontainers for each run. It also needs RustFS running, so start the dev stack first.
Put a test beside the file it tests, as name.test.ts. Use createTestUser and contextFor to call a procedure as a given role. There's a full example in Adding a procedure.
Test files run one at a time. Each test resets the database first, so they can't run side by side.
Storybook
Every shared-ui component and every web-app page has stories, covering loading, empty, error, and read-only states. API calls are mocked with MSW, from handlers typed against the real router.
yarn storybook:dev
Add a story beside the component, as Name.stories.tsx. Use a play() function to reach a state that needs a click.