Skip to content

Enable testing with strict mode for the entire app #633

@matej-ibis-ai

Description

@matej-ibis-ai

I have seen issues with some of my functional components processed/created by Reagent when using the React strict mode. However, it doesn't seem possible to define tests in Reagent that reproduce the issue because, as far as I can tell, the top-level component in tests is always reagent$dom$client$reagent_root. When I define a custom component and run reagenttest.utils/with-render in my test, following the example of existing tests, adding [:> react/StrictMode #js {} ...] there doesn't have the desired effect because it's not at the top level and so React does not run the extra cycle of React effect hooks (see the note at the end of this chapter of React docs).

As of this writing, I have been able to reproduce my issue only by replacing the .render call in the reagent.dom.client/render function with:

(.render root
         (react/createElement
          react/StrictMode
          #js {}
          (react/createElement reagent-root js-props)))

I think this should be exposed to tests as a regular option of the testing functions (with-render in particular).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions