Skip to content

Commit

Permalink
Merge pull request #289 from testing-library/simplify-act
Browse files Browse the repository at this point in the history
chore: simplify implementation of act
  • Loading branch information
yanick authored Jan 24, 2024
2 parents 9ef86c7 + f5121e1 commit 9fdce65
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/pure.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,9 @@ const cleanup = () => {
Array.from(containerCache.keys()).forEach(cleanupAtContainer)
}

const act = (fn) => {
const value = fn && fn()
if (value !== undefined && typeof value.then === 'function') {
return value.then(() => tick())
const act = async (fn) => {
if (fn) {
await fn()
}
return tick()
}
Expand Down

0 comments on commit 9fdce65

Please sign in to comment.