This project has unit tests, accessibility tests, and linting checks.

Unit tests (Mocha)

Run the unit tests:

npm run test:unit

Accessibility tests (axe + Puppeteer)

Run the accessibility test suite (builds first, then runs Jest):

npm run test:axe

Accessibility tests have a couple of known issues around colour contrast in headless browsers. See docs/accessibility-testing.md for details.

All tests

Run unit, aspComponent, and accessibility tests:

npm test

That is test:unit, test:component, then test:axe.

Linting

Run all linters:

npm run lint

That runs ESLint, Stylelint, and component YAML contract validation (validate:contracts).

Run individually:

npm run lint:js
npm run lint:css
npm run validate:contracts

GitHub Actions runs CSS lint, contract validation, and manifest checks. See docs/ci.md.

Component YAML contracts (validate:contracts)

scripts/validate-contracts.js checks that each component’s YAML examples match the JSON Schema declared in that component’s YAML.

JSON Schema files live beside the YAML (for example src/njk/components/alert/alert.schema.json). Each schema’s root $id is a stable logical URN (urn:asp-frontend:component:<id>); it is not required to resolve over HTTP.

This checks examples vs schema, not Nunjucks template behaviour. After changing params, examples, or schemas, run npm run validate:contracts (or npm run lint) before pushing.

Component manifest (build:manifest / validate:manifest)

scripts/build-component-manifest.js scans src/njk/components//macro.njk and src/twig/components//macro.twig, verifies macro names match, and writes:

After adding or renaming a component macro, run npm run build:manifest. CI runs npm run validate:manifest (same script with --check) as part of npm run lint.

Nunjucks resolves macros at runtime via the manifest; Twig/PHP use the generated dispatch file.

validate:contracts also verifies every component with a JSON Schema has a matching manifest entry.

aspComponent unit tests

npm run test:component

See docs/asp-component.md for the Node module layout.

.NET tests

dotnet test src/dotnet/tests/AspFrontend.Tests/AspFrontend.Tests.csproj -c Release

Source

Imported from docs/testing.md in asp-frontend.