(janitor/test-prune): Remove tautological/duplicate tests in utils.test.ts - #5492
Merged
Conversation
- Remove the two 'compile-time test' cases for assertNotNullish and toNonNullish. Both self-describe as TypeScript narrowing checks; any regression there would be caught by tsc/typecheck, not by these runtime assertions. The runtime throw/no-throw behavior they exercise is already fully covered by the adjacent tests in the same describe blocks. - Remove 'should preserve console.log behavior on JSON parse error' in parseResultJsonWithZodSchema tests. It never asserts anything about console.log, and duplicates the exact setup/execution/assertion of 'should handle error response when JSON parsing fails' one test above it (same createMockResponse(400, 'Bad Request', null, true) input, same rejects.toThrow assertion).
pandemicsyn
approved these changes
Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes three low-value tests from
apps/web/src/lib/utils.test.tsthatcannot detect a plausible production regression and add ongoing
maintenance cost without protecting any additional behavior. No
production code changed.
Removed tests and surviving coverage
1.
assertNotNullish— "should properly narrow types (compile-time test)"assertNotNullish."compile-time test." If the type declaration on
assertNotNullishwere wrong,
tsc/pnpm typecheckwould fail — not this test. Atruntime, the test only calls
assertNotNullishwith non-null values(no-throw path) and then calls built-in
String.toUpperCase/Number.toFixed, which exercise no additional branch ofassertNotNullish.should not throw when value is not null or undefined(non-null/undefined inputs, no-throw path) andshould throw a custom error message when provided(null/undefined inputs,throw path and custom message) in the same
describe('assertNotNull')block fully cover the function's only two runtime branches.
neighboring tests already detect — a broken narrowing type
declaration is caught by typecheck, not by this test.
2.
toNonNullish— "should properly narrow return type (compile-time test)"toNonNullish(whichsimply calls
assertNotNullishand returns the value).should return the value when it is not null or undefinedandshould throw an error when value is null or undefinedindescribe('requireNotNull')cover both runtimebranches (return value, throw with default/custom message).
3.
parseResultJsonWithZodSchema— "should preserve console.log behavior on JSON parse error"failure — but the test body never references
console.logorspies on it.
immediately above it — same
createMockResponse(400, 'Bad Request', null, true)setup, samerejects.toThrow('Failed to fetch data: Bad Request')assertion — minus that test'sjsonMockcall-countcheck. It tests strictly less than its neighbor while claiming to
test something (console logging) that isn't asserted at all.
should handle error response when JSON parsing fails(immediately preceding test) exercises the identicalcode path with an equal-or-stronger assertion (adds the
jsonMockcall-count check).JSON-parse-failure path is already caught by the preceding test with
an equal or stronger assertion.
Verification
apps/webtests require a reachable PostgreSQL instance viasetupFilesAfterEnv(workerSetup.ts), which is unavailable in thissandbox (no docker/postgres). Ran a full repo-wide
tsc --noEmitattempt, but it exceeded the sandbox's memory/time limits and could
not complete.
oxlint --config .oxlintrc.json apps/web/src/lib/utils.test.tsdirectly on the changed file: 0 warnings, 0 errors.
oxfmton the changed file (repo formatter) — no formattingdrift beyond the deletions.
apps/web/src/lib/utils.ts(assertNotNullish,toNonNullish,parseResultJsonWithZodSchema) to confirm everyruntime branch removed tests exercised remains covered by a
surviving test with an equal or stronger assertion.
git diff --check— no whitespace issues.No production code, other test files, or unrelated tests were touched.