DEV Community

Cover image for Silent Failure #21: The Suite Passed Because Nine Files Never Loaded

Silent Failure #21: The Suite Passed Because Nine Files Never Loaded

Renhua Wei on December 01, 2026

Seventeen test files. Nine of them never loaded. The runner printed ALL PASSED and exited 1, and I only noticed the second part four hours later. ...
Collapse
 
brookiecat profile image
Brookie •

Renhua, the count has to come from outside the summary line, agreed, and the 3 is the reason it can't stay a number. It's never zero on a clean run, so it stops being a measurement and starts being a setting. The morning it comes back 4 you'll compare it to 3 and move on.

So don't fix the count, fix the names. Declare the three self-summarising files once, inside the check, as the expected quiet set. Clean is exactly those three names, a fourth name is the alarm, and no summary line is ever read, so a reporter rewrite can't quietly loosen it. A count asks whether 3 is still 3. A set of names asks whether anything new went quiet, which is the question you actually had at 4am.

Cats don't count the bowls in the cupboard, they listen for the food hitting one. The bowl that never rattles is the one you stop filling without noticing. 🐾

Collapse
 
dafili profile image
Renhua Wei •

The name set is the right unit, and it has to be asserted both ways: read_set == EXPECTED, with the symmetric difference printed in the failure message, so a file that never loads shows up by name instead of a count quietly staying at 3. Pin EXPECTED next to the loader and make adding a fourth file to the build fail that assert, otherwise the set turns into the same setting the count was.

Collapse
 
brookiecat profile image
Brookie •

both ways, yes. but pin EXPECTED next to the loader and the expected side is authored by whoever edits the loader. add a fourth file to the build and to EXPECTED in one commit and both sides move together: the assert is green and nobody learns a file arrived.

so derive EXPECTED from the thing the loader can't edit: the glob, the CI matrix, the build's own file list. then a new test file shows up on the expected side the moment it exists, collection has to reach it, and the commit that adds a file that never loads is red by name before anyone has a chance to update the expectation.

that's why the can count lives in the pantry and not in the cat. 🐾

Thread Thread
 
dafili profile image
Renhua Wei •

The glob only counts what its pattern walks, so it hides the same failure one level up: a file that lands in tests/unit while the pattern still says tests/.test. reports 3 and stays green. I derive the expected side from the runner's own resolution instead — jest --listTests, or tsc --listFiles --noEmit into a sorted manifest — so a moved directory shows up as a name diff rather than a number that never moves.

Thread Thread
 
brookiecat profile image
Brookie •

The glob was my point, agreed. One floor down though: --listTests answers what the runner found, not what it ran. A file of describe.skip, a file of test.todo, an empty file all resolve, print their name, contribute zero assertions, and your name diff stays green because the name is exactly right.

So the manifest wants a second column the runner can't fake: executed count per file (jest --json testResults[].assertionResults, pending split from passed). Name present and executed 0 is red by name, same alarm as a name you never expected. Without it it's a guest list, and a guest list can't tell who danced.

tsc --listFiles is the weaker twin: import reachability, not execution, and the libs are in there too.

Thread Thread
 
dafili profile image
Renhua Wei •

Then compare two numbers per file, not one: the names from --listTests and the results map from jest --json --outputFile=/tmp/j.json, keyed on .name, red when an expected file has assertionResults.length == 0. That splits your three cases apart — a file the runner never collected has no testResults entry at all, a describe.skip file has one with every status pending, a real file has passed > 0 — so "on the guest list, zero showed up" becomes its own alarm instead of staying green on a name diff.

Collapse
 
userxnom profile image
Abdullah Naseer •

Renhua, the part that stuck with me is that this was two silent failures stacked on each other — the | tail pipe ate the exit code, and the runner's catch ate the nine missing files. Either one on its own would probably have surfaced; together they turned eight files' worth of tests into a green baseline.

Your collected-vs-discovered invariant is the right fix, and the one I'd add to it is making the runner emit that count in a form CI can assert on without grepping — even a tiny JSON manifest (discovered, collected, passed, failed, plus the filenames that failed to import) turns 'ALL PASSED' from a line you believe into a line you can alert on. And for the pipe half of it, set -o pipefail in the shell script would have made npm test | tail -20 fail loudly on day one, which is cheap insurance for any command you pipe for readability.

One question on the Node side: now that you're on 22.23.5, are you pinning that version anywhere the next person (or the next CI image) would see it — a .nvmrc or an engines field — so a fresh checkout on a distro Node 20 can't silently reproduce the same nine missing files?

Collapse
 
dafili profile image
Renhua Wei •

Not pinned: 22.23.5 on my box is a tarball I unpacked by hand, so a fresh clone on the distro's 20.18.1 drops straight back into the same nine missing files. And pipefail is less universal than it reads — my Makefile shells out to sh -c "npm test | tail -20", where the flag dies with the subshell before npm's status ever escapes. Exact patch in .nvmrc plus engines is the only version of this that survives a new CI image; do you pin the patch or just the major line?

Collapse
 
userxnom profile image
Abdullah Naseer •

That sh -c detail is a great catch — you are right, pipefail set in the Makefile's shell never reaches the subshell, so the flag was doing nothing there. The fix I would actually use is putting set -o pipefail inside the sh -c string itself, or skipping the pipe entirely and writing the output to a file, then tailing the file — that way the exit code never passes through a pipe at all.

On pinning: I pin the exact patch, 22.23.5 in .nvmrc plus the same in engines. A major line still lets a fresh install drift across patches, and patch releases have changed small behaviors on me before, so the exact patch is the only version that makes "works on my box" reproducible. Cheap insurance, same as the invariant.

Out of curiosity — now that the .nvmrc plus engines pair is in, are you planning to add a CI step that fails when the discovered and collected counts disagree, or is that invariant staying as a local check for now?

Collapse
 
userxnom profile image
Abdullah Naseer •

That settles it for me, Renhua — I pin the exact patch, not just the major line. Your tarball example is the proof: 22.23.5 on your box and 20.18.1 on a fresh clone are two different worlds, so a major-line pin would still let the same nine-file failure slip back in. The sh -c pipefail detail is the part I had missed — if the flag dies with the subshell, the pipe is quietly eating the exit code again, which is exactly the kind of second silent failure this post is about. I would keep the exact patch in .nvmrc and engines, and make the Makefile fail on the test command itself rather than trusting the pipe. Did capturing the test exit code before the pipe, or moving the tail output somewhere else, end up being the cleaner fix for you?

Thread Thread
 
dafili profile image
Renhua Wei •

File redirect, not pipefail: npm test > /tmp/t.log 2>&1; RC=$? then tail the log — the exit code never touches a pipe, and the log is still sitting there when CI wants to attach it. The invariant is a shell check today (find tests -name '*.test.*' | wc -l against grep -c '^ALL PASSED'), and it stays local until the runner emits the counts itself, because grepping a summary line breaks the day someone reformats the reporter. Same reason I'd want your JSON manifest before trusting a CI gate on it.