Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

Commit 9303163

Browse files
committed
fix: improve flushing
1 parent 5f1a56d commit 9303163

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

test/handle.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import * as path from 'path'
55
import {CLIError, config, ExitError} from '../src'
66
import {handle} from '../src/handle'
77

8-
const wait = (ms: number) => new Promise(resolve => setTimeout(() => resolve(), ms).unref())
98
const errlog = path.join(__dirname, '../tmp/mytest/error.log')
109

1110
describe('handle', () => {
@@ -56,7 +55,7 @@ describe('handle', () => {
5655
handle(new CLIError('uh oh!'))
5756
expect(ctx.stderr).to.equal(' ✖ Error: uh oh!\n')
5857
expect(process.exitCode).to.equal(2)
59-
await wait(10)
58+
await config.errorLogger!.flush()
6059
expect(fs.readFileSync(errlog, 'utf8')).to.contain('Error: uh oh!')
6160
})
6261
})

test/warn.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import * as path from 'path'
44

55
import {config, warn} from '../src'
66

7-
const wait = (ms: number) => new Promise(resolve => setTimeout(() => resolve(), ms).unref())
87
const errlog = path.join(__dirname, '../tmp/mytest/warn.log')
98

109
describe('warn', () => {
@@ -14,9 +13,9 @@ describe('warn', () => {
1413
.finally(() => config.errlog = undefined)
1514
.it('warns', async ctx => {
1615
warn('foo!')
17-
await wait(51)
1816
expect(ctx.stderr).to.contain('Warning: foo!')
1917
expect(process.exitCode).to.be.undefined
18+
await config.errorLogger!.flush()
2019
expect(fs.readFileSync(errlog, 'utf8')).to.contain('Warning: foo!')
2120
})
2221
})

0 commit comments

Comments
 (0)