You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 00fb8f2
Browse filesBrowse the repository at this point in the historyBrowse files
fix(tests): silence 'failed to persist' noise from incomplete D1 mocks (#680)
Two root causes:
1. Incomplete mocks — `logEvent` and `logError` call `env.DB.prepare(sql).run()`
(no `.bind()` in between) for their probabilistic retention DELETEs (1% and 2%
respectively). Twenty-one hand-written D1 stubs only implemented the bound path
`prepare().bind().run()` and had no top-level `run()`, so every time the coin
landed the logger printed `[events] failed to persist: prepare(...).run is not
a function` to stderr — noise that caused #624's misattribution.
Fix: add `async run() { return { meta: { changes: 0 } }; }` directly on the
object returned by `prepare()` in all 21 affected stubs.
2. Intentional error tests — three "never throws even if the DB blows up" tests
used `{ prepare() { throw } }` to force the failure path, which correctly
exercised the code but also emitted the console.error lines as a side-effect
(the tests passed, so nothing caught the noise). These are now fixed with
`vi.spyOn(console, "error")` so the test captures the error output and asserts
it was called, instead of letting it bleed to the test runner's stderr.
Result: 10,206 tests pass, zero "failed to persist" lines on a green run.
The two pre-existing pdf-lib test failures are unrelated and pre-existed this change.
Closes#680
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments