Skip to content

Commit 6aaef17

Browse files
committed
chore(coverage): exclude tests code from coverage report
1 parent a479b87 commit 6aaef17

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

jest.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
22
preset: 'ts-jest',
33
testEnvironment: 'node',
4+
collectCoverageFrom: ['src/**/*'],
45
}

src/PostgrestBuilder.ts

+1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ export default abstract class PostgrestBuilder<Result, ThrowOnError extends bool
222222
* @deprecated Use overrideTypes<yourType, { merge: false }>() method at the end of your call chain instead
223223
*/
224224
returns<NewResult>(): PostgrestBuilder<CheckMatchingArrayTypes<Result, NewResult>, ThrowOnError> {
225+
/* istanbul ignore next */
225226
return this as unknown as PostgrestBuilder<
226227
CheckMatchingArrayTypes<Result, NewResult>,
227228
ThrowOnError

test/basic.ts

+36
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,42 @@ test('basic select returns from builder', async () => {
140140
`)
141141
})
142142

143+
test('basic select with maybeSingle yielding more than one result', async () => {
144+
const res = await postgrest.from('users').select().maybeSingle()
145+
expect(res).toMatchInlineSnapshot(`
146+
Object {
147+
"count": null,
148+
"data": null,
149+
"error": Object {
150+
"code": "PGRST116",
151+
"details": "Results contain 5 rows, application/vnd.pgrst.object+json requires 1 row",
152+
"hint": null,
153+
"message": "JSON object requested, multiple (or no) rows returned",
154+
},
155+
"status": 406,
156+
"statusText": "Not Acceptable",
157+
}
158+
`)
159+
})
160+
161+
test('basic select with single yielding more than one result', async () => {
162+
const res = await postgrest.from('users').select().single()
163+
expect(res).toMatchInlineSnapshot(`
164+
Object {
165+
"count": null,
166+
"data": null,
167+
"error": Object {
168+
"code": "PGRST116",
169+
"details": "The result contains 5 rows",
170+
"hint": null,
171+
"message": "JSON object requested, multiple (or no) rows returned",
172+
},
173+
"status": 406,
174+
"statusText": "Not Acceptable",
175+
}
176+
`)
177+
})
178+
143179
test('basic select view', async () => {
144180
const res = await postgrest.from('updatable_view').select()
145181
expect(res).toMatchInlineSnapshot(`

0 commit comments

Comments
 (0)