Testing in CI

Page content:

postdoc test exits with a non-zero code when a test or check fails, which fails the CI job.

GitHub Actions

The Ubuntu runners have Chrome installed:

yaml
name: Docs

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: 22
          cache: npm
      - run: npm ci
      - run: npx postdoc check
      - run: npx postdoc test --report page-checks.json

postdoc check takes seconds and finds what a browser isn't needed for, such as broken links, so the job fails early when there is one. --report writes what the page checks found as JSON, for a later step to read.

Deploy what was tested

postdoc test leaves the build in the output folder, so a later step can deploy exactly what was tested. GitHub Pages has a workflow that tests the site and then deploys it.

Edit this page on GitHub