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

Support use in act testing API #25523

Merged
merged 1 commit into from
Oct 21, 2022
Merged

Commits on Oct 20, 2022

  1. Support use in act testing API

    `use` can avoid suspending on already resolved data by yielding to
    microtasks. In a real, browser environment, we do this by scheduling
    a platform task (i.e. postTask).
    
    In a test environment, tasks are scheduled on a special internal queue
    so that they can be flushed by the `act` testing API. So we need to add
    support for this in `act`.
    
    This behavior only works if you `await` the thenable returning by
    `act` call. We currently do not require that users do this. So I added
    a warning, but it only fires if `use` was called. The old Suspense
    pattern will not trigger a warning. This is to avoid breaking existing
    tests that use Suspense.
    
    The implementation of `act` has gotten extremely complicated because of
    the subtle changes in behavior over the years, and our commitment to
    maintaining backwards compatibility. We really should consider being
    more restrictive in a future major release.
    
    The changes are a bit confusing so I did my best to add inline comments
    explaining how it works.
    acdlite committed Oct 20, 2022
    Configuration menu
    Copy the full SHA
    65d6fc6 View commit details
    Browse the repository at this point in the history