Merge pull request 'fix(tests): the error-handling suite would not compile, and nothing local said so (#307)' (#323) from fix/307-integration-typecheck into main
Linting / lint (push) Successful in 4m31s
SonarQube Analysis / sonarqube (push) Failing after 34m21s

Reviewed-on: #323
This commit was merged in pull request #323.
This commit is contained in:
2026-09-09 08:51:33 -05:00
2 changed files with 8 additions and 1 deletions
+1
View File
@@ -8,6 +8,7 @@
},
"scripts": {
"build": "tsc",
"typecheck:tests": "tsc -p tsconfig.test.json --noEmit",
"lint": "eslint src scripts tests",
"start": "node dist/server.js",
"dev": "tsx watch src/server.ts",
@@ -34,7 +34,13 @@ const DB_FAILURE = 'invalid input syntax for type integer while reading items';
* spy is not sensitive to how the module is transpiled.
*/
function failNextQuery() {
return jest.spyOn(pool, 'query').mockRejectedValueOnce(new Error(DB_FAILURE));
// `as never` is the type system, not a shortcut. `pg` declares `query` with
// several overloads, and `jest.spyOn` resolves the mock's argument against
// the last of them, whose parameter list is empty — so the inferred type for
// a rejection value is `never` and nothing can be assigned to it. Rejecting
// is what all of the overloads do on failure; the cast only says which one to
// check against.
return jest.spyOn(pool, 'query').mockRejectedValueOnce(new Error(DB_FAILURE) as never);
}
describe('unexpected route failures', () => {