Skip to content

Commit b468cb6

Browse files
committed
fix: remove captureOutput from tests that expect errors
The log-displayer tests that expect errors were wrapping displayer.display() in captureOutput, which was causing the tests to hang. Since these tests are only checking error messages and not stdout/stderr output, we can remove the captureOutput wrapper and catch the errors directly in try-catch blocks.
1 parent 65c39cb commit b468cb6

1 file changed

Lines changed: 8 additions & 19 deletions

File tree

test/unit/lib/run/log-displayer.unit.test.ts

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -353,22 +353,17 @@ describe('logDisplayer', function () {
353353

354354
context('when the log server responds with a stream of log lines and then timeouts', function () {
355355
it('displays log lines and exits showing a timeout error', async function () {
356-
let stdout = ''
357356
try {
358-
const output = await captureOutput(async () => {
359-
await displayer.display({
360-
app: 'my-cedar-app',
361-
tail: true,
362-
})
357+
await displayer.display({
358+
app: 'my-cedar-app',
359+
tail: true,
363360
})
364-
stdout = output.stdout
361+
expect.fail('Expected error to be thrown')
365362
} catch (error: unknown) {
366363
const {message, oclif} = error as CLIError
367364
expect(message).to.equal('Logs eventsource failed with: 401')
368365
expect(oclif.exit).to.eq(1)
369366
}
370-
371-
expect(stdout).to.eq('')
372367
})
373368
})
374369
})
@@ -388,22 +383,16 @@ describe('logDisplayer', function () {
388383
})
389384

390385
it('displays logs and recreates log sessions on timeout', async function () {
391-
let stderr = ''
392386
try {
393-
const output = await captureOutput(async () => {
394-
await displayer.display({
395-
app: 'my-fir-app',
396-
tail: false,
397-
})
387+
await displayer.display({
388+
app: 'my-fir-app',
389+
tail: false,
398390
})
399-
stderr = output.stderr
391+
expect.fail('Expected error to be thrown')
400392
} catch (error: unknown) {
401393
const {message} = error as Error
402394
expect(message.trim()).to.equal('HTTP Error 500 for POST https://api.heroku.com/apps/my-fir-app/log-sessions')
403395
}
404-
405-
// it displays message about fetching logs for fir apps
406-
expect(stderr).to.eq('Fetching logs...\n\n')
407396
})
408397
})
409398
})

0 commit comments

Comments
 (0)