Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 06f7b4f

Browse files
authoredJun 22, 2021
act should work without mock Scheduler (#21714)
Currently, in a React 18 root, `act` only works if you mock the Scheduler package. This was because we didn't want to add additional checks at runtime. But now that the `act` testing API is dev-only, we can simplify its implementation. Now when an update is wrapped with `act`, React will bypass Scheduler entirely and push its tasks onto a special internal queue. Then, when the outermost `act` scope exists, we'll flush that queue. I also removed the "wrong act" warning, because the plan is to move `act` to an isomorphic entry point, simlar to `startTransition`. That's not directly related to this PR, but I didn't want to bother re-implementing that warning only to immediately remove it. I'll add the isomorphic API in a follow up. Note that the internal version of `act` that we use in our own tests still depends on mocking the Scheduler package, because it needs to work in production. I'm planning to move that implementation to a shared (internal) module, too.
1 parent 422e0bb commit 06f7b4f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+423
-1004
lines changed
 

‎fixtures/dom/src/__tests__/nested-act-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('unmocked scheduler', () => {
4848
TestAct(() => {
4949
TestRenderer.create(<Effecty />);
5050
});
51-
expect(log).toEqual(['called']);
51+
expect(log).toEqual([]);
5252
});
5353
expect(log).toEqual(['called']);
5454
});

‎fixtures/dom/src/__tests__/wrong-act-test.js

Lines changed: 0 additions & 207 deletions
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.