function withUnhandledRejectionCaptured(asyncFn) {
  const next = rejectionTestsQueueHandle.promise.then(() => {
    const originalHandlers = process.listeners('unhandledRejection')
    process.removeAllListeners('unhandledRejection')
    const repair = () => {
      process.removeAllListeners('unhandledRejection')
      originalHandlers.forEach((handler) => {
        process.on('unhandledRejection', handler)
      })
    }
    return new Promise((resolve, reject) => {
      process.on('unhandledRejection', (error) => {
        console.error('unhandledRejection', error.message)
        repair()
        reject(error)
      })
      setTimeout(() => {
        repair()
        resolve('Timed out without unhandledRejection.')
      }, 5000)

      asyncFn()
    })
  })
  rejectionTestsQueueHandle.promise = next.catch(() => {}) // don't pollute current test with errors from previous
  return next
}
Disables the unhandledRejection listener temporarily to avoid AVA's global
listener from catching the rejection.

I'll regret this.

I had to avoid overlapping execution from different tests

@param {async function} asyncFn