Tests live alongside the code they exercise.
A Vitest projects configuration at the repo root discovers each app's vitest.config.ts, so tests for all apps run from a single command.
The site app uses jsdom for component tests and plain Node for utility/config tests; the docs app uses plain Node for config tests.
apps/site/src/
config/
navigation.ts
navigation.test.ts <- data-driven config tests
util/
slugify.ts
slugify.test.ts <- pure unit tests
components/
layout/
SearchInput.tsx
SearchInput.test.tsx <- React component tests
apps/docs/src/
config/
sidebar.ts
sidebar.test.ts <- sidebar structure tests
# single run (all projects)
npm test
# watch mode
npm run test:watch
# browser UI
npm run test:ui
# single project only
npx vitest run --project @bdc/site
npx vitest run --project @bdc/docsEnsuring the UI stays predictable is key to its sustainability and success. To help increase the probability of producing a stable application, we adhere to a test-driven development workflow.
The following steps should be followed when developing new features.
-
Define the feature and any associated data or interface changes.
-
Write tests that validate the desired behavior or data structure.
Note: These tests will fail at first. That's the point.
-
Implement the feature to make the tests pass.
-
Refine: iterate on the implementation and tests until behavior is correct and edge cases are covered.
-
Build UI support for any restructured data, if applicable.
-
Validate: run the full test suite and confirm nothing else broke.
Not every file needs a test. Focus testing effort where it provides the most value:
- Utility functions: pure functions with well-defined inputs and outputs, e.g., slugify utility.
- Configuration data: structural invariants on config objects, e.g., nav item structure.
- React components: user-facing behavior: rendering, interaction, accessibility, e.g., SearchInput interactivity
- Data transforms: any logic that reshapes content or API responses for the UI, e.g., news/event grouping-by-tag function
Avoid testing framework internals, Astro's build pipeline, or third-party library behavior.
- Test files are co-located with the module they test:
foo.ts→foo.test.ts. - Use
describe/itblocks with human-readable descriptions. - Prefer
@testing-library/reactfor component tests: query by role, label, or text, not implementation details. - Keep tests focused. One behavior per
itblock.
Automated accessibility audits run in CI using Playwright and axe-core. Every page in the built site is tested against WCAG 2.0/2.1 Level AA to satisfy Section 508 requirements.
# audit specific pages against a running dev server
npm run a11y:page -w @bdc/site -- http://localhost:4321/about
# build & test key pages
npm run a11y:smoke -w @bdc/site
# build & test every page in the sitemap
npm run a11y:full -w @bdc/siteSee apps/site/a11y/README.md for configuration details, compliance targets, and how to add exceptions.