Skip to content

Commit

Permalink
fix: allow waitFor(async () => {}) to work
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Dec 18, 2020
1 parent 01570d3 commit e778c7f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class WaitFor {
numAttempts++
const thisAttemptStartTime = new Date().getTime()
try {
await this.buildAssertion()
const assertion = await this.buildAssertion()
if (assertion) await assertion._obj
} catch (error) {
const now = new Date().getTime()

Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('waitFor', function () {
waitFor(async () => {
await new Promise((resolve) => setTimeout(resolve, 200))
if (i++ < 3) throw new Error('TEST')
}).to.be.fulfilled,
}),
clock.tickAsync(1001),
])
expect(i).to.equal(4)
Expand Down

0 comments on commit e778c7f

Please sign in to comment.