Skip to content

Commit

Permalink
feat: do not await the returned promise
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed May 17, 2024
1 parent 9244f27 commit 9c89781
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,7 @@ export function createInternalSpy<A extends any[], R>(
throw err
}
}
let resultTuple: ResultFn<R> = [type, result]
if (isPromise(result)) {
const newPromise = result
.then((r: any) => (resultTuple[1] = r))
.catch((e: any) => {
// @ts-expect-error TS for some reasons narrows down the type
resultTuple[0] = 'error'
resultTuple[1] = e
throw e
})
// we need to reassign it because if it fails, the suite will fail
// see `async error` test in `test/index.test.ts`
Object.assign(newPromise, result)
result = newPromise
}
state.results.push(resultTuple)
state.results.push([type, result])
return result
} as SpyInternal<A, R>

Expand Down

0 comments on commit 9c89781

Please sign in to comment.