Frontend unit tests cover durations, colours, statistics and health (closes #21)
check / check (push) Successful in 3m38s
check / check (push) Successful in 3m38s
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 an empty history, an all-unreachable one, a mixed one, one of only answers and one whose answers have different numbers of digits, and the four health states either side of their thresholds, with targets found unreachable counted as timed out. 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 was merged in pull request #99.
This commit is contained in:
+11
-3
@@ -1,14 +1,22 @@
|
||||
#!/bin/sh
|
||||
# script/frontend-test: run the frontend test suite: the unit tests in
|
||||
# test/unit/ with Node's built-in test runner, then the production
|
||||
# build, which fails on broken code.
|
||||
# test/unit/, through the test script in package.json, then the
|
||||
# production build, which fails on broken code. The tests print a dot
|
||||
# each; if any fails, they run again with every test listed, and the
|
||||
# script fails even if that run passes. NODE_OPTIONS chooses the
|
||||
# reporter because yarn adds its arguments after the test files, where
|
||||
# node would take a reporter option for one more file.
|
||||
set -eu
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||
|
||||
main() {
|
||||
cd "$ROOT"
|
||||
timeout 30 node --test test/unit/*.test.js
|
||||
NODE_OPTIONS=--test-reporter=dot timeout 30 yarn --silent run test || {
|
||||
echo "--- Rerunning with every test listed for details ---"
|
||||
NODE_OPTIONS=--test-reporter=spec timeout 30 yarn --silent run test
|
||||
exit 1
|
||||
}
|
||||
timeout 30 yarn build
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user