Skip to content

wait not triggered on non hook updates #393

Closed
@AugustinLF

Description

@AugustinLF

Describe the feature you'd like:

wait from asyncUtilities is only called when the hooks updates, and can't be used to check on side-effects. As far as I know, this is different from the behaviour of the wait exposed from @testing-library/dom or the one of @testing-library/react-native which to me was very confusing.

I have a hook that does some async work, then dispatches a redux action. I was doing a await wait(() => expect(store.dispatch).toHaveBeenCalled()). My test never resolved, replacing the wait from renderHook to the one exported in @testing-library/react made my test pass.

Suggested implementation:

I didn't look enough to the implementation of these two libraries' wait, but perhaps something similar could be made? I would be totally ok with contributing and opening such a PR if you're ok.

Teachability, Documentation, Adoption, Migration Strategy:

There shouldn't be any change of API, and this would not be a breaking change, so I guess this wouldn't be ok?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions