Skip to content

Commit d8fb2f9

Browse files
authored
test: Avoid silencing errors from idle timeout test’s child process (#3419)
This hid the error fixed in #3263, for example.
1 parent 9b51037 commit d8fb2f9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Diff for: packages/pg-pool/test/idle-timeout.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -89,28 +89,30 @@ describe('idle timeout', () => {
8989

9090
it('unrefs the connections and timeouts so the program can exit when idle when the allowExitOnIdle option is set', function (done) {
9191
const child = fork(path.join(__dirname, 'idle-timeout-exit.js'), [], {
92-
silent: true,
92+
stdio: ['ignore', 'pipe', 'inherit', 'ipc'],
9393
env: { ...process.env, ALLOW_EXIT_ON_IDLE: '1' },
9494
})
9595
let result = ''
9696
child.stdout.setEncoding('utf8')
9797
child.stdout.on('data', (chunk) => (result += chunk))
9898
child.on('error', (err) => done(err))
99-
child.on('close', () => {
99+
child.on('exit', (exitCode) => {
100+
expect(exitCode).to.equal(0)
100101
expect(result).to.equal('completed first\ncompleted second\n')
101102
done()
102103
})
103104
})
104105

105106
it('keeps old behavior when allowExitOnIdle option is not set', function (done) {
106107
const child = fork(path.join(__dirname, 'idle-timeout-exit.js'), [], {
107-
silent: true,
108+
stdio: ['ignore', 'pipe', 'inherit', 'ipc'],
108109
})
109110
let result = ''
110111
child.stdout.setEncoding('utf8')
111112
child.stdout.on('data', (chunk) => (result += chunk))
112113
child.on('error', (err) => done(err))
113-
child.on('close', () => {
114+
child.on('exit', (exitCode) => {
115+
expect(exitCode).to.equal(0)
114116
expect(result).to.equal('completed first\ncompleted second\nremoved\n')
115117
done()
116118
})

0 commit comments

Comments
 (0)