Testing and Code Quality¶
Commands¶
| Command | What it does |
|---|---|
pnpm test |
Run the tests once |
pnpm test:watch |
Run the tests, re-running on every change |
pnpm test:coverage |
Run the tests with a coverage report |
pnpm lint |
Check the code with ESLint; any warning fails |
pnpm lint:fix |
Fix what ESLint can fix automatically |
pnpm format |
Format src/ with Prettier |
pnpm format:check |
Check src/ is formatted, without changing it |
pnpm exec tsc --noEmit |
Type-check without building |
Tests¶
Tests use Vitest with a simulated browser (jsdom) and Testing Library. They sit next to the code they test, as *.test.ts or *.test.tsx. Shared setup is in src/test/setup.ts.
The tests don't need Canopy: services and contexts are tested with mocked responses.
Pre-commit Hook¶
pnpm install sets up a git pre-commit hook (with Husky) that runs:
pnpm exec tsc --noEmit, so a commit with type errors is refused.lint-staged, which runs on the files being committed only:*.ts,*.tsx:eslint --fix, thenprettier --write*.css,*.md:prettier --write
Files changed by the hook are added to the commit.
Markdown is formatted too
Prettier formats the docs as you commit them. This affects tip and warning boxes; see Writing Docs.
Continuous Integration¶
| Workflow | Runs on | Checks |
|---|---|---|
lint.yml |
Pull requests and pushes to main |
pnpm lint, pnpm format:check, and tsc --noEmit |
test.yml |
Pull requests and pushes to main |
pnpm test |
gh-pages.yml |
Pull requests that change the docs, and pushes to main |
mkdocs build --strict; on main, publishes the docs site |
tauri.yml |
Pushes to main, or run by hand for any branch |
Builds the RPM, as a downloadable artifact |
build-dev.yml |
Pushes to main |
Builds the RPM and publishes the dev-<commit> and dev-latest pre-releases |
build-release.yml |
Published releases | Builds the RPM and attaches it to the release |
build-image.yml |
Pull requests and pushes to main, or run by hand |
Builds the web container image; on main, publishes it |
lint.yml, test.yml and build-image.yml call shared workflows from slaclab/swapps-ci-helpers. The lint check and the RPM builds use Node 23.11.
These workflows only build and publish. SLAC's deployments run from the internal slaclab/swapps-sf-deployment repository; see its apps/react-squirrel/README.md.