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

Replace global jest heuristic with IS_REACT_ACT_ENVIRONMENT #22562

Merged
merged 2 commits into from
Oct 18, 2021

Commits on Oct 18, 2021

  1. Remove jest global check in concurrent roots

    In concurrent mode, instead of checking `jest`, we check the new
    `IS_REACT_ACT_ENVIRONMENT` global. The default behavior is `false`.
    
    Legacy mode behavior is unchanged.
    
    React's own internal test suite use a custom version of `act` that works
    by mocking the Scheduler — rather than the "real" act used publicly. So
    we don't enable the flag in our repo.
    acdlite committed Oct 18, 2021
    Configuration menu
    Copy the full SHA
    5e74830 View commit details
    Browse the repository at this point in the history
  2. Warn if act is called in wrong environment

    Adds a warning if `act` is called but `IS_REACT_ACT_ENVIRONMENT` is not
    enabled. The goal is to prompt users to correctly configure their
    testing environment, so that if they forget to use `act` in a different
    test, we can detect and warn about.
    
    It's expected that the environment flag will be configured by the
    testing framework. For example, a Jest plugin. We will link to the
    relevant documentation page, once it exists.
    
    The warning only fires in concurrent mode. Legacy roots will keep the
    existing behavior.
    acdlite committed Oct 18, 2021
    Configuration menu
    Copy the full SHA
    80fb358 View commit details
    Browse the repository at this point in the history