Skip to content

Your web browser is out of date

Your web browser (the software you use to access the internet) is out of date. You need to update it or use a different web browser to ensure you can complete this form.

Cookies disabled

Cookies are currently not enabled in your web browser. You need to enable cookies to ensure you can complete this form.

Testing

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.

  • Components are discovered under src/njk/components/<id>/ when <id>.yaml includes schema.jsonSchema (path to the schema file, relative to the YAML file).
  • For every examples[].options entry, the script validates the object with Ajv against the referenced *.schema.json.
  • Each example’s options (macro arguments) are wrapped as { type: "<componentId>", params: <options> } before validation — the same shape passed to aspComponent at render time.

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:

  • src/component-manifest.json — registry used by aspComponent in Node and PHP
  • src/twig/internal/asp-component-dispatch.twig — generated Twig dispatch (do not edit by hand)

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.


Published 23 September 2026
Last updated 23 September 2026