Frontend unit tests cover durations, colours, statistics and health (closes #21)
check / check (push) Successful in 4m19s
check / check (push) Successful in 4m19s
New table-driven tests in test/unit/main.test.js: humanDuration, the figure and sparkline colours either side of each latency boundary, a target's min, max, average and median over empty, all-unreachable and mixed histories, and the four health states either side of their thresholds. src/main.js exports the four names they need. package.json gains a test script, which script/frontend-test runs with the dot reporter and, if a test fails, again with the spec reporter before failing. NODE_OPTIONS picks the reporter, since yarn appends its arguments after the test files. Model: opus-5-5
This commit is contained in:
@@ -47,15 +47,17 @@ halves, so the root `make check` fails if either one is broken. We provide:
|
||||
- `script/setup` — make a fresh clone ready for development: bootstrap plus the
|
||||
git pre-commit hook
|
||||
- `script/projectname` — print the project name (used for the Docker image tag)
|
||||
- `script/test` — run `script/frontend-test`, then the backend's Go tests, each
|
||||
under its own 30-second timeout
|
||||
- `script/test` — run `script/frontend-test`, then `backend/script/test`, the
|
||||
backend's Go tests with the race detector and coverage
|
||||
- `script/lint` — run eslint, then golangci-lint, both in Docker, by building
|
||||
the `frontend-lint` and `lint` stages of `Dockerfile` without the cache
|
||||
- `script/fmt` — format all files (writes): prettier, then gofmt over `backend/`
|
||||
- `script/fmt-check` — check formatting (read-only): prettier, then gofmt
|
||||
- `script/check` — run test, lint, and fmt-check
|
||||
- `script/frontend-test` — run the unit tests in `test/unit/` with Node's
|
||||
built-in test runner, then the production build
|
||||
built-in test runner, through the `test` script in `package.json`, and if any
|
||||
fails, run them again listing every test, and fail; then the production build.
|
||||
Each run has a 30-second timeout
|
||||
- `script/frontend-lint` — run eslint with the rules in `eslint.config.js`; it
|
||||
runs inside the `frontend-lint` stage of `Dockerfile`, which `make lint`
|
||||
builds
|
||||
@@ -267,7 +269,6 @@ properties.
|
||||
|
||||
## TODO
|
||||
|
||||
- Add unit tests
|
||||
- Add configurable host list (environment variable or config file)
|
||||
- Add latency history export (CSV/JSON)
|
||||
- Add notification/alert when status changes to DEGRADED
|
||||
|
||||
Reference in New Issue
Block a user