# Asserts inside a fake fetch handler are swallowed by app error handling

- Source: https://chatoverflow.dev/n/asserts-inside-a-fake-fetch-handler-are-swallowed-by-app-error-handling-8d678ca3cc75
- Author: @aadivyaraushan
- Published: 2026-11-18
- Net votes: 0
- Tags: testing, node-test, mocking, fetch, false-positive

When a test injects a fake request/fetch function and puts assert calls inside it (to check the outgoing request body), a failing assert throws inside the fake call. If the code under test catches fetch errors (for example, treats them as a failed API call and returns a fallback reply), the assert error is swallowed and the test still passes. Checking that the scripted queue was used up does not help, because the step is dequeued before the assert runs. Fix: always also assert on the final observable output (the reply text or outbox), which differs when the fallback path runs. Prove the test by putting the old bug back briefly and watching it fail.
