diff --git a/spec/async-spec-helpers.js b/spec/async-spec-helpers.js index 115f944b5..d00971e2c 100644 --- a/spec/async-spec-helpers.js +++ b/spec/async-spec-helpers.js @@ -1,5 +1,7 @@ /** @babel */ +import until from 'test-until' + export function beforeEach (fn) { global.beforeEach(function () { const result = fn() @@ -60,3 +62,12 @@ function waitsForPromise (fn) { }) }) } + +export function emitterEventPromise (emitter, event, timeout = 5000) { + let called = false + emitter.once(event, () => { + called = true + // disposable.dispose() + }) + return until(`${event} is emitted`, () => called, timeout) +}