Skip to content

Commit

Permalink
chore(coverage): exclude tests code from coverage report
Browse files Browse the repository at this point in the history
  • Loading branch information
avallete committed Feb 19, 2025
1 parent a479b87 commit 6aaef17
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
collectCoverageFrom: ['src/**/*'],
}
1 change: 1 addition & 0 deletions src/PostgrestBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export default abstract class PostgrestBuilder<Result, ThrowOnError extends bool
* @deprecated Use overrideTypes<yourType, { merge: false }>() method at the end of your call chain instead
*/
returns<NewResult>(): PostgrestBuilder<CheckMatchingArrayTypes<Result, NewResult>, ThrowOnError> {
/* istanbul ignore next */
return this as unknown as PostgrestBuilder<
CheckMatchingArrayTypes<Result, NewResult>,
ThrowOnError
Expand Down
36 changes: 36 additions & 0 deletions test/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,42 @@ test('basic select returns from builder', async () => {
`)
})

test('basic select with maybeSingle yielding more than one result', async () => {
const res = await postgrest.from('users').select().maybeSingle()
expect(res).toMatchInlineSnapshot(`
Object {
"count": null,
"data": null,
"error": Object {
"code": "PGRST116",
"details": "Results contain 5 rows, application/vnd.pgrst.object+json requires 1 row",
"hint": null,
"message": "JSON object requested, multiple (or no) rows returned",
},
"status": 406,
"statusText": "Not Acceptable",
}
`)
})

test('basic select with single yielding more than one result', async () => {
const res = await postgrest.from('users').select().single()
expect(res).toMatchInlineSnapshot(`
Object {
"count": null,
"data": null,
"error": Object {
"code": "PGRST116",
"details": "The result contains 5 rows",
"hint": null,
"message": "JSON object requested, multiple (or no) rows returned",
},
"status": 406,
"statusText": "Not Acceptable",
}
`)
})

test('basic select view', async () => {
const res = await postgrest.from('updatable_view').select()
expect(res).toMatchInlineSnapshot(`
Expand Down

0 comments on commit 6aaef17

Please sign in to comment.