Skip to content

Run the unit tests in CI, and fail the gate when none run - #15

Merged
systemslibrarian merged 1 commit into
mainfrom
fix/unit-tests-actually-run
Sep 22, 2026
Merged

systemslibrarian merged 1 commit into
mainfrom
fix/unit-tests-actually-run

Conversation

@systemslibrarian

@systemslibrarian systemslibrarian commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

From the findings in systemslibrarian/crypto-lab#2 ("the unit-test step runs 0 tests").

Why no tests ran

The unit tests are TypeScript that Node runs through its own type stripping (import … from './oracle.ts'). The deploy workflow pinned Node 20, which has no type stripping, so node --test never looked at .ts files. It found nothing to run and exited 0. The latest main build (run 35186536668, commit e57bb57) logged:

# tests 0
# pass 0
# fail 0

and the gate passed.

The fix

  • CI uses Node 24. The same test files load, and 13 tests run.

  • npm test now runs scripts/test.mjs. This drives node:test's own runner over src/**/*.test.ts and exits non-zero if:

    • no file matches;
    • the matched files define no tests (node:test reports such a file as one passing "test" named after the file, so those are subtracted);
    • any test fails.

    node --test alone exits 0 on an empty run, even for a glob that matches nothing.

Checked locally before pushing: the real suite passes with 13 tests. Each failure case exits 1: a pattern matching no files, a matched file with no tests, and a failing test. Loading the runner under Node 20 fails immediately rather than passing.

Test count from this PR's CI log

From this PR's run (35753742748, commit bfa6c00), step Run tests:

node-version: 24
Run npm test
ℹ tests 13
ℹ pass 13
ℹ fail 0
Unit tests run: 13

On main, the same step (run 35186536668) reported # tests 0.

Nothing else changed: no test, source or other workflow step.

Generated with Claude Code

The unit tests are TypeScript that Node runs through its own type stripping
(they import './oracle.ts'). CI pinned Node 20, which has no type stripping, so
`node --test` discovered no test files at all and the deploy gate passed with
"# tests 0" — run 35186536668 on e57bb57.

- CI uses Node 24, where the same files load and 13 tests run.
- `npm test` now runs scripts/test.mjs, which drives node:test's own runner
  over src/**/*.test.ts and exits non-zero if no file matches, if the matched
  files define no tests, or if any test fails. `node --test` alone exits 0 on
  an empty run, including for a glob that matches nothing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant