A green test run tells you that no assertion failed. It does not tell you that any assertion ran. I found that out about my own work. In three small public projects, four different mechanisms let tests pass without checking what their names claim. This article walks through each one, shows how I confirmed it, and turns the confirmation steps into a method you can run on your own suite.
The code comes from my public repositories:
RESTful Booker API automation (opens in a new tab) at commit a385240,
Razorpay payment gateway QA (opens in a new tab) at da9e7a2
and ERPNext QA automation (opens in a new tab) at 8990014.
Every excerpt links to the exact lines at the commit it came from.
Read this first. I ran RESTful Booker and Razorpay on 30 November 2026 with Playwright 1.63.0 and retries off. Every change I made to prove a point was in a scratch copy, and I have not changed any of the public repositories. Case 4 was not run. The ERPNext instance the project used is offline, so that case comes from reading the code and the repository's own root-cause document.
Four cases from three small projects show that each mechanism exists, not how common it is.
1. Why a green run proves little
Most reviews of a test suite ask what the tests do when they fail. The harder question is whether they can fail. A test can be green because the application is right, because the test never reached an assertion, or because the assertion cannot be false. On a CI dashboard those three look the same.
All four cases are in code I wrote. I confirmed three of them by breaking the application, or the test, on purpose and watching what stayed green, and the fourth by reading the code. The breaking technique is what this article is really about.
2. Case 1: a matcher with no parentheses
In the RESTful Booker suite, three negative tests record that the API accepts unusual input: a negative price, an invalid date string and a checkout date before the check-in. Each one ends with the same assertion.
test('POST /booking with negative price is accepted by API', async ({ request }) => {
const bookingWithNegativePrice = {
...validBooking,
totalprice: -100,
};
const response = await bookingClient.postResponse('/booking', bookingWithNegativePrice);
expect(response.ok).toBeTruthy();
});
In Playwright, response.ok is a method. Without the call parentheses the expression is
the function itself, which is always truthy, so toBeTruthy() can never fail. I covered
the bug in section 4 of the API testing lessons article.
Here is what I added for this one.
I pointed the three tests at a local server that answers 500 to everything, using the
BASE_URL variable the suite already reads. As written, all three passed. After I changed
the three lines to response.ok(), all three failed with Received: false.
Against the real API the corrected versions still pass, so the fix changes only whether the suite could notice a change. The whole
suite, untouched, passed 47 of 47. Three of those 47 could not have failed.
3. Case 2: assertions inside an if
The Razorpay project has a test, ORDER-003, that checks the server ignores an amount
and currency sent by the client. Its assertions sit inside an if.
test('ORDER-003: client-supplied amount/currency cannot override the backend-controlled order amount', async ({ request }) => {
const response = await request.post('/api/payments/create-order', {
data: { amount: 1, currency: 'USD' },
});
if (response.status() === 200) {
const body = await response.json();
// Backend ignores whatever the client sent and always uses config.js's amount/currency
expect(body.amount).toBe(50000);
expect(body.currency).toBe('INR');
}
});
In CI the workflow supplies placeholder credentials so the app's validation paths run. With them,
the call to Razorpay fails (the server log shows Authentication failed) and the app answers
400 to create-order.
I called the endpoint to check: 400, "Failed to create order". So ORDER-003
never reaches its assertions in CI. ORDER-001 has the same shape. It asserts only when
the status is 200 or 503, gets 400, and asserts nothing either.
To see what that costs, I edited the two lines in create-order that set the amount and
currency so they took the client's values from req.body. The CI-safe suite still
passed 34 of 34. As a control, I also replaced the gateway call in that scratch copy with a stub so
order creation succeeds. ORDER-003 then failed with Expected: 50000, Received: 1.
The assertion is correct. It just never runs where CI can see it.
The payment article covers this as
lesson 5. The point I add is about reporting: a test that cannot reach its assertions should say skipped, because passed is a claim, and here it is a false one.
4. Case 3: tests that can only reject
DEF-002 was the best defect in the Razorpay project. A global
express.json() parser was mounted before the webhook route, so no correctly signed
webhook could ever be accepted. The story is in the
payment article and the defect
report is in the Evidence Library. Its regression tests make a good test
of the test suite, because I can put the bug back.
// The webhook route needs the exact raw request body to verify Razorpay's
// HMAC signature (see docs/DEFECTS.md, DEF-002). It must be mounted BEFORE
// the global express.json() parser below - otherwise express.json() would
// consume and parse the body first, and the webhook route's own
// express.raw() middleware (src/routes/webhooks.js) would never see the
// original bytes. Every other route still gets normal JSON parsing via the
// global middleware mounted after this.
app.use('/api/webhooks', webhooksRouter);
// ...
app.use(express.json());
In a scratch copy I moved the webhook router line to after express.json() and changed
nothing else. Then I ran the 11 tests in webhook-validation.spec.js, with the placeholder
environment and retries off.
| Test | What it needs from the route | Result |
|---|---|---|
WEB-001, WEB-005, WEB-006, WEB-FIX-001, WEB-FIX-004 | A valid webhook is accepted | All 5 failed |
WEB-002, WEB-FIX-002, WEB-FIX-003 | A signature that does not match is rejected | Still passed |
WEB-003, WEB-004 | A missing header is rejected | Still passed |
WEB-007 | A tampered payload is rejected | Failed, for the wrong reason |
Six failed and five passed. Every test that needs the route to accept a valid webhook
failed: 5 of 5. Of the six tests that only check rejection, 5 still passed. A correctly signed
webhook got 401 Webhook signature validation failed, so the app was rejecting
everything, including the requests those tests expect it to reject. WEB-003 and
WEB-004 are turned away by header checks that run before the body is read, so the
parser order cannot touch them.
test('WEB-FIX-003: an invalid signature is rejected', async ({ request }) => {
const orderId = 'order_webfix_' + Date.now();
const paymentId = 'pay_webfix_' + Date.now();
const eventId = 'evt_webfix_invalid_' + Date.now();
const payload = shapedPayload(orderId, paymentId);
const response = await request.post('/api/webhooks/razorpay', {
data: payload,
headers: {
'X-Razorpay-Signature': 'f'.repeat(64),
'X-Razorpay-Event-Id': eventId,
'Content-Type': 'application/json',
},
});
expect(response.status()).toBe(401);
const body = await response.json();
expect(body.error).toBe('Unauthorized');
});
WEB-007 is the mirror image. It appends a character to the payload, which makes the body
invalid JSON. With the bug present, the JSON parser answers 400 before the route runs,
and the test expects 401 (Expected: 401, Received: 400). The others pass for
the wrong reason, and this one fails for the wrong reason. In both directions the result says nothing
about the signature check.
A rejection test tells you the guard exists. Only an acceptance test tells you the door still opens. A suite with only the first kind can stay green through a defect that locks everyone out.
5. Case 4: a catch that presses Enter
This case is from reading code, not from a run. The ERPNext project drives a hosted ERPNext instance that is offline. I could not execute anything, so I cannot show whether a wrong selection would have got through.
In the Quotation page object, setCustomer waits up to three seconds for the matching
autocomplete option and clicks it. If the wait or the click fails, it presses Enter instead.
const autocompleteOption = this.page.locator('[role="option"]:has-text("' + customerName + '")').first();
try {
await autocompleteOption.waitFor({ state: 'visible', timeout: 3000 });
// Click the matching option
await autocompleteOption.click();
} catch {
// If autocomplete doesn't appear, try pressing Enter
await input.press('Enter');
}
The Sales Order page object has the same pattern in
its setCustomer, lines 78 to 84 (opens in a new tab).
Both came in with the repository's first commit
(4e13b0c (opens in a new tab))
and are still there on main
(bd3846a, 22 October 2026 (opens in a new tab),
which only changed the CI workflow).
The repository did fix a related problem. Item selection used to have a similar fallback
.click().catch(async () => { await input.press('Enter') }) (opens in a new tab), and commits 94d2045 and 2fdd673 replaced it with typed input and keyboard selection. They did not touch setCustomer. The
ERPNext case study describes that fix,
and I have now scoped its wording to item selection.
What do the specs check? Both workflow specs call setCustomer and then print
Step 3: Selected customer whether or not anything was selected. The only assertion in each
is that the URL after saving is not /new. The same specs have a step labelled "Verify
amount calculation" that computes expectedAmount
(quotation spec, lines 57 to 59 (opens in a new tab))
and never asserts on it.
So the accurate statement is this: the specs passed without verifying the customer, and I cannot show whether a wrong selection would have got through. ERPNext may reject a missing or invalid customer when the document is saved, which would stop the test. I would find out by running it against a live instance, and I cannot do that today.
6. What the four cases have in common
| Case | Why it stayed green | How I checked it |
|---|---|---|
1. response.ok | The assertion is on a function, which is always truthy | A server that answers 500 |
2. Assertions in an if | CI never takes the branch, so no assertion runs | Counting expect calls, and a client-trusting scratch copy |
| 3. Rejection-only tests | A broken app rejects everything, so the rejections still pass | Putting the bug back |
| 4. Catch that presses Enter | A fallback keeps the test moving after a failed step, and a log line reports success anyway | Reading the code (not run) |
None of the four shows up as a failure, a flake or a skip. A suite like this reports the same thing whether the application is right or wrong, and that is the property to look for.
7. A method for auditing your own suite
Break it on purpose
Pick a behaviour the suite claims to protect and break it in a scratch copy. Revert a fix, hard-code a wrong value, or point the tests at a stub that answers 500. Run the suite and list what stayed green. Then ask which of those tests claim to protect the thing you broke. I confirmed cases 1, 2 and 3 above this way, and each break was one to three lines. Do it in a copy, never in the repository you ship from.
Run it with retries off, and more than once
npx playwright test --retries=0 --repeat-each=3
Razorpay's config retries twice in CI. With retries off and each test repeated three times, its CI-safe suite gave 102 passed on 30 November 2026.
Retries turn a flaky test green, and repeating each test makes a flaky one fail more often.
Playwright 1.63.0, the version I ran, also has --fail-on-flaky-tests, which fails the run when a test only passed on a retry. Its config form, failOnFlakyTests, is listed as added in v1.52 in the
TestConfig reference (opens in a new tab).
Check your own version. None of the four cases was flaky, so this step alone would not have found them.
Grep for the usual shapes
# 1. a method used without its parentheses
grep -rnE "expect\(\w*[rR]esponse\.(ok|status|json|text)\)" tests
# 2. assertions near an if (candidates to read, not verdicts)
grep -rnE -A8 "^\s*(\} else )?if \(" tests | grep "expect("
# 3. every catch, to read one by one
grep -rnE "\.catch\(|catch *(\(|\{)" tests pages
# 4. fixed sleeps
grep -rn "waitForTimeout" tests pages
My own starting points, run from each repository's root. They are heuristics, not detectors.
On the three repositories at the commits above, the first pattern matched exactly lines 35, 48 and 61
of the RESTful Booker spec and nothing in the other two. The second listed the ORDER
tests in Razorpay, plus some tests that assert in both branches and are fine. The third matched
33 lines in ERPNext, most of them harmless, such as .isVisible().catch(() => false), plus the
two setCustomer fallbacks, and none in the other two. The fourth found 23 fixed sleeps
in ERPNext and none elsewhere. The first pattern only matches a variable named response,
so adjust all four to your code.
Count the assertions that actually ran
class CountExpects {
counts = new Map();
onStepEnd(test, result, step) {
if (step.category === 'expect')
this.counts.set(test.id, (this.counts.get(test.id) || 0) + 1);
}
onTestEnd(test, result) {
if (!this.counts.get(test.id)) console.log('ZERO-EXPECT', result.status, test.title);
}
}
module.exports = CountExpects;
A scratch reporter I wrote for this article, not from any repository. Save it as count-expects.cjs, which keeps it working in projects set to "type": "module", and run npx playwright test --reporter=./count-expects.cjs.
On Razorpay's CI-safe suite it printed two lines, for ORDER-001 and ORDER-003,
both with status passed. That is case 2, found without editing any code. It printed
nothing for RESTful Booker, so it cannot catch case 1:
expect(response.ok).toBeTruthy() is still an expect call. The reporter counts
calls, and the grep in the previous step is what finds a call that cannot fail.
Pair every rejection with an acceptance
For each test that proves something is refused, keep one that proves the same path accepts valid
input, and have the second assert an effect, not just a status code. In the webhook spec,
WEB-FIX-001 sends a valid signature and checks the order became paid.
WEB-FIX-003 sends a bad one and expects 401. Only the first one noticed the
bug in case 3.
8. A checklist you can copy
- Break the application in a scratch copy and list every test that stays green.
- Run with
--retries=0 --repeat-each=3. If your Playwright version has--fail-on-flaky-tests, consider it for CI. - Grep for assertions on a method without its parentheses, such as
response.ok. - Find every assertion inside an
if,elseortry, and decide whether CI ever takes that branch. - Read every
catchand.catch(). Remove any that lets the test carry on after a failed step. - Search for
waitForTimeoutand replace each one with an assertion on the state you are waiting for. - Count the
expectcalls each test makes, and investigate every test with zero. - For every rejection test, find its acceptance twin. If there is none, write it.
- Assert effects, such as the state after a call, not only status codes.
- If a test cannot reach its assertions in CI, make it report
skipped, notpassed. - Do not count a log line such as "Step 3 passed" as an assertion.
9. What this does not show
- Frequency. Four cases from three small projects I wrote say nothing about how common these patterns are elsewhere, and I make no such claim.
- Case 4 was not run. It is a reading of the code at the cited commits. Whether a wrong customer would have got through the save step is unknown.
- The scratch changes are not published. Each was one to three lines, described above, and not committed anywhere.
- Public repositories are unchanged. I have not fixed any of these issues there, so the links show the problems at the commits I cite.
- Sandboxes, not production. RESTful Booker is a public practice API and Razorpay was used in Test Mode. Nothing here says how a production system behaves.
- The tools are heuristics. The grep patterns are tuned to my code and will miss shapes I have not seen. The reporter counts
expectcalls, not how good they are. - No employer work. Every case here is from my own public repositories.