Skip to content

Commit

Permalink
Fix flaky test (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Dec 14, 2018
1 parent 1c0d1ea commit 1e980de
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,18 +274,19 @@ test('outpipe', function (t) {
.plugin(splitRequirePath)
.plugin(splitRequirePlugin, { out: output })
.bundle()
.pipe(fs.createWriteStream(path.join(actualDir, 'bundle.js')).on('finish', onbuilt))
.pipe(fs.createWriteStream(path.join(actualDir, 'bundle.js')))
.on('error', t.fail)
.on('finish', onbuilt)

var i = 0
function onbuilt () {
if (++i < 2) return
var actual = readTree.sync(actualDir, { encoding: 'utf8' })
t.deepEqual(Object.keys(actual).sort(), [
'bundle.1.js', 'bundle.js'
], 'should have generated 2 files')
rimraf.sync(actualDir)
t.end()
// wait for a bit because it's not flushed yet
setTimeout(function () {
var actual = readTree.sync(actualDir, { encoding: 'utf8' })
t.deepEqual(Object.keys(actual).sort(), [
'bundle.1.js', 'bundle.js'
], 'should have generated 2 files')
rimraf.sync(actualDir)
t.end()
}, 100)
}
})

0 comments on commit 1e980de

Please sign in to comment.