Fix CI: npm test's glob pattern doesn't expand on Node 20
"tsx --test test/**/*.test.ts" worked locally (Node v22) and failed on the CI runner (node:20-alpine, Node v20) with: Could not find '.../server/test/**/*.test.ts' node --test only gained native glob-pattern CLI arguments around Node 21/22; on Node 20 the literal glob string is treated as a single filename and, unsurprisingly, not found. Same script, two Node majors, different behavior - not a shell/quoting issue (both runs go through tsx's own CLI, no shell glob expansion involved either way). Fixed by listing the four test files explicitly instead of relying on a glob whose CLI support turned out to vary across the exact two Node installs this project runs on (this dev machine, and node:20-alpine - the CI container and server/Dockerfile's runtime image, deliberately matched). engines.node is >=18, so relying on a 21/22-only feature was already a latent bug even before it showed up. Verified locally (all 25 tests still pass with the explicit list) - the actual node:20-alpine behavior will confirm on the next CI run. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
b2310216ce
commit
4eab0323d6
2 changed files with 18 additions and 1 deletions
|
|
@ -1088,6 +1088,23 @@ jobs clone sources by hand with `git init`/`fetch`/`checkout` rather than
|
||||||
jobs don't share a filesystem, so each clones independently; `publish`
|
jobs don't share a filesystem, so each clones independently; `publish`
|
||||||
only starts once `test` succeeds.
|
only starts once `test` succeeds.
|
||||||
|
|
||||||
|
**A real failure on the very first two runs**, caught by actually watching
|
||||||
|
the pipeline rather than assuming green: `"test": "tsx --test
|
||||||
|
test/**/*.test.ts"` worked perfectly locally and failed on the runner with
|
||||||
|
`Could not find '.../test/**/*.test.ts'`, as if the literal glob string
|
||||||
|
had been handed to Node as a filename. It had - `node --test` gained
|
||||||
|
native glob-pattern CLI arguments only around Node 21/22, and this dev
|
||||||
|
machine's global `node` is v22, while the CI job (deliberately pinned to
|
||||||
|
`node:20-alpine`, matching `server/Dockerfile`'s runtime image) is v20 -
|
||||||
|
same script, two Node majors, one of which silently doesn't glob-expand
|
||||||
|
the argument at all and just looks for a file with `*` characters in its
|
||||||
|
literal name. Fixed by listing the four test files explicitly in the
|
||||||
|
script instead of trusting a glob to be interpreted the same way on every
|
||||||
|
Node version this project targets (`engines.node` is `>=18`) - a
|
||||||
|
one-time list-maintenance cost in exchange for not depending on a CLI
|
||||||
|
feature whose availability turned out to vary across the exact two Node
|
||||||
|
installs this project actually runs on.
|
||||||
|
|
||||||
Client: since esbuild bundles everything into one `app.js` (no more
|
Client: since esbuild bundles everything into one `app.js` (no more
|
||||||
individually-importable view modules the way separate `<script
|
individually-importable view modules the way separate `<script
|
||||||
type="module">` files were before), testing moved from "import one view
|
type="module">` files were before), testing moved from "import one view
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
"start": "node dist/index.js",
|
"start": "node dist/index.js",
|
||||||
"dev": "tsx watch src/index.ts",
|
"dev": "tsx watch src/index.ts",
|
||||||
"typecheck": "tsc -p tsconfig.test.json",
|
"typecheck": "tsc -p tsconfig.test.json",
|
||||||
"test": "tsx --test test/**/*.test.ts"
|
"test": "tsx --test test/catalogService.test.ts test/musicQueueService.test.ts test/partyService.test.ts test/socketGateway.test.ts"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue