Skip to content

Commit 06b19ac

Browse files
committed
add comment to act hacky emit
1 parent 36f6f09 commit 06b19ac

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/Vitest.ReactTestingLibrary/Library.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ type RTL =
340340
static member cleanup () : unit = jsNative
341341

342342
[<ImportMember("@testing-library/react")>]
343-
// [<Emit("new Promise((resolve, reject) => { $0(async () => { await $1(); resolve() }) })")>]
343+
// Note: Why this emit? Fable.Promise `do!` will call a `_.then(...)` after resolving the promise, this will throw an error with the `act` function.
344+
// therefore i wrap it inside another async function which will return a promise that can be awaited.
344345
[<Emit("(async () => await $0($1))()")>]
345346
static member act (actFn: unit -> Promise<unit>) : Promise<unit> = jsNative
346347

0 commit comments

Comments
 (0)