forked from brianc/node-postgres
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasync-stack-trace-tests.js
More file actions
42 lines (39 loc) · 1.2 KB
/
Copy pathasync-stack-trace-tests.js
File metadata and controls
42 lines (39 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict'
const helper = require('../test-helper')
const pg = helper.pg
const suite = new helper.Suite()
suite.test('promise API async stack trace in pool', async function outerFunction() {
async function innerFunction() {
const pool = new pg.Pool()
await pool.query('SELECT test from nonexistent')
}
try {
await innerFunction()
throw Error('should have errored')
} catch (e) {
const stack = e.stack
if (!e.stack.includes('innerFunction') || !e.stack.includes('outerFunction')) {
throw Error('async stack trace does not contain wanted values: ' + stack, { cause: e })
}
}
})
suite.test('promise API async stack trace in client', async function outerFunction() {
async function innerFunction() {
const client = new pg.Client()
await client.connect()
try {
await client.query('SELECT test from nonexistent')
} finally {
client.end()
}
}
try {
await innerFunction()
throw Error('should have errored')
} catch (e) {
const stack = e.stack
if (!e.stack.includes('innerFunction') || !e.stack.includes('outerFunction')) {
throw Error('async stack trace does not contain wanted values: ' + stack, { cause: e })
}
}
})