axecov

package
v0.41.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package axecov is the axe-coverage manifest shared between the axe test harness and strict mode. The harness (framework/testkit/axetest) calls Record after every successful scan, accumulating which URL paths the app's accessibility tests actually exercised; uihost strict mode reads the result with Read and refuses to serve a page route no axe test covers.

The manifest lives at .gofastr/axe-coverage.json under the canonical coverage root (DefaultDir: GOFASTR_AXE_COVERAGE_DIR, else the module root, else the working directory) so the writer (tests) and the readers (strict mode) agree even when their working directories differ. `.gofastr/` is a local build-artifact directory (gitignored, wiped by `make clean`), so the manifest never ships: strict mode only enforces axe coverage in dev, where the file exists.

This package is deliberately dependency-free (no chromedp) so production code can read manifests without linking a headless browser.

Index

Constants

View Source
const FileName = ".gofastr/axe-coverage.json"

FileName is the manifest location relative to the app/test working directory.

Variables

This section is empty.

Functions

func DefaultDir

func DefaultDir() string

DefaultDir is the canonical coverage-root both the writer (the axe test harness) and the readers (uihost strict mode, tooling) resolve, so the manifest lands where enforcement looks for it even when the test package dir and the server working directory differ (the `gofastr dev --dir <root> --pkg ./cmd/app` layout):

  1. GOFASTR_AXE_COVERAGE_DIR, when set — the explicit override.
  2. The nearest ancestor containing go.work — Go's own workspace rule. A test binary in a workspace's nested module (/repo/apps/shop) and a dev server at the workspace root (/repo) both find /repo/go.work, so they resolve the same directory.
  3. Else the nearest ancestor containing go.mod (the module root).
  4. Else the working directory itself.

Known limitation: several apps sharing one module (or workspace) share one manifest, and coverage is keyed by route path — two strict apps with the same route ("/", "/login") can satisfy each other's check. Set GOFASTR_AXE_COVERAGE_DIR per app (both when running its tests and its server) when that matters; single-app modules — every generated app — are unaffected.

func Record

func Record(dir, path, scheme string) error

Record merges one scanned page into dir's manifest, creating the manifest (and .gofastr/) on first use. path may be a full URL or a bare path — the query string and fragment are stripped, because coverage is per screen, not per parameter combination.

Types

type Manifest

type Manifest struct {
	Version int                 `json:"version"`
	Pages   map[string][]string `json:"pages"`
}

Manifest maps every scanned URL path to the color schemes it was scanned under.

func Read

func Read(dir string) (*Manifest, error)

Read loads dir's manifest. A missing manifest returns an error satisfying errors.Is(err, fs.ErrNotExist) — callers decide whether absence is fatal (strict dev) or fine (production).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL