Skip to content
This repository was archived by the owner on Jun 17, 2024. It is now read-only.
This repository was archived by the owner on Jun 17, 2024. It is now read-only.

UseEffect hook and testing-library #839

@wynsoft

Description

@wynsoft

Hi Kent,

Sorry to bother you but I have a component that has a few useEffect hooks. Each of them is responsible to do a single task. One reads the params from the URL as stores it in state using the useState hook. The second useEffect checks if the params from the URL are set in state and then makes an API call to fetch some data. I want to be able to test the API call from the second useEffect and check if it has been called and with what it has been called with. When the API succeeds it calls a function that dispatches updates to the context. I would like to test this call to this function and also the dispatched within it.

Is this possible to do with the testing-library? If so, your guidance on how to achieve this will be highly appreciated.

Thanks,

Derrick.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions