Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactTestUtils.actAsync returned promise can't be used more than once #627

Open
TristanCacqueray opened this issue Oct 19, 2020 · 2 comments

Comments

@TristanCacqueray
Copy link

TristanCacqueray commented Oct 19, 2020

It seems like the actAsync Promise is broken and it results in undefined error when used twice, for example:

actAsync(_ => () |> resolve) |> then_(_ => () |> resolve)  |> then_(_ => () |> resolve)

yield this error: TypeError: Cannot read property 'then' of undefined

More details in: glennsl/rescript-jest#77

@bloodyowl
Copy link
Contributor

The actAsync function in React doesn't return an actual promise, I think you can fix that by doing:

@bs.val external toActualPromise: Js.Promise.t<'a> => Js.Promise.t<'a> = "Promise.resolve";

toActualPromise(actAsync(...))

@TristanCacqueray
Copy link
Author

Thank you for the feedback, this solution works. Shouldn't it be the default so that actAsync can be used directly with Jest.testPromise ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants