diff --git a/backend/package.json b/backend/package.json index 9f7654a..494afe1 100755 --- a/backend/package.json +++ b/backend/package.json @@ -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", diff --git a/backend/tests/integration/errorHandling.integration.test.ts b/backend/tests/integration/errorHandling.integration.test.ts index 36e8fa5..bfbc8bb 100644 --- a/backend/tests/integration/errorHandling.integration.test.ts +++ b/backend/tests/integration/errorHandling.integration.test.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', () => {