- Home
- Skills
- Testing & Debugging
- Hollow Test Guard: Tests That Can Actually Fail
Hollow Test Guard: Tests That Can Actually Fail
Tests that fail when the code breaks: a checklist and rewrite rules for the hollow-test patterns found even in popular open source projects.
Free
Works with the AI Agents you already use
Hollow Test Guard: Tests That Can Actually Fail
Example session with this skill installed
Review this test file and tell me which tests can never fail: it("adds", () => { add(1,2) }); it("is null", () => { expect(find()).toBeNull }); it("loads", async () => { expect(load()).resolves.toBe(1) }); it("throws", () => { try { parse("") } catch (e) { expect(e.message).toBe("empty") } }); it("sums", () => { expect(add(2,2)).toBe(4) });
- Read your context and instructions
- Compiled the hollow test guard
Four of the five tests are weak. Three can effectively never fail on a wrong result, and one fails only in some cases.
Can never fail on a wrong result
addshas no assertion. It passes unlessaddthrows, soadd(1,2)returning 99 still passes.
is null writes toBeNull without parentheses. That only reads the matcher function and never calls it, so nothing is asserted. It passes whatever find() returns. The fix is toBeNull().
3.
loads neither awaits nor returns the .resolves assertion. The test finishes before the promise settles, so a wrong value or a rejection never fails it. Depending on the runner, it may show up later as an unhandled rejection or be swallowed. The fix is await expect(load()).resolves.toBe(1).
Can fail, but not in the main failure case
throws passes silently if parse("") doesn't throw, because the expect lives only in the catch. That is the main regression it should catch. It does fail if the error has a different message. The fix is expect(() => parse("")).toThrow("empty"), or add expect.assertions(1).
Fine
sumscallsadd(2,2)and assertstoBe(4), so it fails ifaddis wrong.
One more point: adds and sums test the same function. adds should assert expect(add(1,2)).toBe(3) or be deleted.
Real output from a Claude Code session with this skill installed.
Connects securely to your tools. The creator never sees your data.
About this skill
Tests that pass while the code is broken provide a false sense of security. This skill identifies and fixes "hollow tests"—assertions that can never fail due to missing awaits, swallowed exceptions, or tautological comparisons. It helps your test suite guard against regressions instead of just inflating coverage metrics.
What it does
- Flags hollow patterns like un-awaited async assertions, assertions inside empty catch blocks, and calls to matchers without parentheses.
- Identifies tautologies where tests compare a variable to itself or a constant, ensuring assertions remain meaningful.
- Detects swallowed errors in Python and JavaScript where
try/exceptortry/catchblocks inadvertently hide assertion failures. - Fixes weak assertions by suggesting specific value checks over generic
toBeTruthyortoBeDefinedcalls. - Audits mocks to ensure you are testing the actual logic rather than mocking the module under test itself.
How it works
- Analyze test files by providing the content of a spec or test file for review.
- Review output generated for each finding, including the file line, test name, the hollow pattern detected, and why it fails to protect the code.
- Apply concrete rewrites based on the provided fixes to turn hollow tests into functional guards.
Frameworks & tools
Supports JavaScript and TypeScript using Jest, Vitest, Mocha, node:test, Playwright, and Testing Library. Supports Python using pytest and unittest.
Why this beats prompting it yourself
Hollow tests look fine at a glance, which is why they survive code review even in well-maintained open source projects. This skill gives your agent a codified list of those anti-patterns to catch specific technical debt that generic prompts miss, such as the difference between expect(x).toBeNull and expect(x).toBeNull().
Use cases
- Reviewing a pull request to ensure new tests actually validate the behavior.
- Troubleshooting a test that stays green even when you manually break the source code.
- Refactoring legacy test suites that rely heavily on generic snapshots or weak assertions.
Known limitations
Does not flag type-level tests, property-based tests, or explicit smoke tests intended only to verify a function does not throw. Requires manual verification of the suggested "correct" value.
Does not flag type-level tests, property-based tests, or explicit smoke tests. Requires manual verification of the suggested correct value.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free forever
No account required to browse
Trust & safety
Security scan
Security scan passed 16 days ago
- Free with an Agensi account
Requires