GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Replace global `jest` heuristic with `IS_REACT_ACT_ENVIRONMENT` by acdlite · Pull Request #22562 · react/react

Conversation

@acdlite

@acdlite acdlite commented Oct 14, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

Refer to reactwg/react-18#102 for context on overall proposal

Based on #22561

In concurrent roots, instead of checking jest, we check the new IS_REACT_ACT_ENVIRONMENT global. The default behavior is false.

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.

Also 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 new warning only fires in concurrent roots. Legacy roots will keep the existing behavior.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@facebook-github-bot facebook-github-bot added the React Core Team Opened by a member of the React Core Team label Oct 14, 2021
acdlite
acdlite commented Oct 14, 2021
View reviewed changes
Comment thread packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js Outdated

@acdlite acdlite Oct 14, 2021

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These warnings no longer fire because our tests don't enable the act environment flag — we mock the Scheduler package instead, or (as in this test) manually flush the microtask queue.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sizebot

sizebot commented Oct 14, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Comparing: 163e81c...80fb358

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 130.15 kB 130.15 kB = 41.41 kB 41.41 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 132.98 kB 132.98 kB = 42.39 kB 42.39 kB
facebook-www/ReactDOM-prod.classic.js = 414.32 kB 414.32 kB = 76.58 kB 76.58 kB
facebook-www/ReactDOM-prod.modern.js = 402.91 kB 402.91 kB = 74.85 kB 74.85 kB
facebook-www/ReactDOMForked-prod.classic.js = 414.32 kB 414.32 kB = 76.58 kB 76.58 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 80fb358

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@acdlite
acdlite force-pushed the replace-jest-heuristic branch from 4453969 to 04c4de3 Compare October 14, 2021 21:18
@facebook-github-bot facebook-github-bot added the CLA Signed label Oct 14, 2021
@acdlite
acdlite marked this pull request as ready for review October 14, 2021 21:19
@acdlite
acdlite requested a review from eps1lon October 14, 2021 21:19
eps1lon
eps1lon reviewed Oct 14, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberAct.new.js Outdated

@eps1lon eps1lon Oct 14, 2021

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this TODO supposed to be part of #22561 but not this PR?

This branch is only handled outside ConcurrentMode which implies to me "legacy mode". But maybe I'm off on the terminology?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

acdlite reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@acdlite acdlite Oct 14, 2021

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I just neglected to delete the comment

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
crypt096
crypt096 approved these changes Oct 16, 2021
View reviewed changes
@acdlite
acdlite force-pushed the replace-jest-heuristic branch from 04c4de3 to 29a0fd3 Compare October 18, 2021 13:38
salazarm
salazarm approved these changes Oct 18, 2021
View reviewed changes

@salazarm salazarm left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
acdlite added 2 commits October 18, 2021 11:28
@acdlite
Remove jest global check in concurrent roots
5e74830
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
Warn if act is called in wrong environment
80fb358
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
acdlite force-pushed the replace-jest-heuristic branch from 2f22a8b to 80fb358 Compare October 18, 2021 15:28
@acdlite
acdlite merged commit 996da67 into react:main Oct 18, 2021
facebook-github-bot pushed a commit to react/react-native that referenced this pull request Nov 2, 2021
Andrei Shikov @facebook-github-bot
React Native sync for revisions afcb9cd...3fcd81d
e161598
Summary:
This sync includes the following changes:
- **[5cccacd](react/react@5cccacd13 )**: Upgrade useId to alpha channel ([#22674](react/react#22674)) //<Andrew Clark>//
- **[75f3dde](react/react@75f3ddebf )**: Remove experimental useOpaqueIdentifier API ([#22672](react/react#22672)) //<Andrew Clark>//
- **[8c4a05b](react/react@8c4a05b8f )**: Remove flow pragma comment from module registration start/stop templates ([#22670](react/react#22670)) //<Brian Vaughn>//
- **[ebf9ae8](react/react@ebf9ae857 )**: useId ([#22644](react/react#22644)) //<Andrew Clark>//
- **[a0d991f](react/react@a0d991fe6 )**: Re-land #22292 (remove uMS from open source build) ([#22664](react/react#22664)) //<Andrew Clark>//
- **[6bce035](react/react@6bce0355c )**: Upgrade useSyncExternalStore to alpha channel ([#22662](react/react#22662)) //<Andrew Clark>//
- **[7034408](react/react@7034408ff )**: Follow-up improvements to error code extraction infra ([#22516](react/react#22516)) //<Andrew Clark>//
- **[90e5d36](react/react@90e5d3638 )**: chore: fix comment typo ([#22615](react/react#22615)) //<btea>//
- **[3c4c1c4](react/react@3c4c1c470 )**: Remove warning for dangling passive effects ([#22609](react/react#22609)) //<Andrew Clark>//
- **[d5b6b4b](react/react@d5b6b4b86 )**: Expand act warning to cover all APIs that might schedule React work ([#22607](react/react#22607)) //<Andrew Clark>//
- **[fa9bea0](react/react@fa9bea0c4 )**: Initial implementation of cache cleanup ([#22510](react/react#22510)) //<Joseph Savona>//
- **[0e8a5af](react/react@0e8a5aff3 )**: Scheduling Profiler: Add marks for component effects (mount and unmount) ([#22578](react/react#22578)) //<Brian Vaughn>//
- **[4ba2057](react/react@4ba20579d )**: Scheduling Profiler: De-emphasize React internal frames ([#22588](react/react#22588)) //<Brian Vaughn>//
- **[cdb8a1d](react/react@cdb8a1d19 )**: [Fizz] Add option to inject bootstrapping script tags after the shell is injected ([#22594](react/react#22594)) //<Sebastian Markbåge>//
- **[34e4c97](react/react@34e4c9756 )**: Clear extra nodes if there's a hydration mismatch within a suspense boundary  ([#22592](react/react#22592)) //<Sebastian Markbåge>//
- **[02f4115](react/react@02f411578 )**: Upgrade useInsertionEffect to stable ([#22589](react/react#22589)) //<Andrew Clark>//
- **[2af4a79](react/react@2af4a7933 )**: Hydrate using SuspenseComponent as the parent ([#22582](react/react#22582)) //<Sebastian Markbåge>//
- **[b1acff0](react/react@b1acff0cc )**: Enable cache in test renderer ([#22580](react/react#22580)) //<Joseph Savona>//
- **[996da67](react/react@996da67b2 )**: Replace global `jest` heuristic with `IS_REACT_ACT_ENVIRONMENT` ([#22562](react/react#22562)) //<Andrew Clark>//
- **[163e81c](react/react@163e81c1f )**: Support disabling spurious act warnings with a global environment flag ([#22561](react/react#22561)) //<Andrew Clark>//
- **[23b7dfe](react/react@23b7dfeff )**: Enable scheduling profiler for RN FB profiling builds ([#22566](react/react#22566)) //<Brian Vaughn>//
- **[61455a2](react/react@61455a25b )**: Enable experimental Cache API in www TestRenderer ([#22554](react/react#22554)) //<Joseph Savona>//
- **[7142d11](react/react@7142d110b )**: Bugfix: Nested useOpaqueIdentifier references ([#22553](react/react#22553)) //<Andrew Clark>//
- **[1e247ff](react/react@1e247ff89 )**: Enabled scheduling profiler marks for React Native FB target ([#22544](react/react#22544)) //<Brian Vaughn>//
- **[c16b005](react/react@c16b005f2 )**: Update test and stack frame code to support newer V8 stack formats ([#22477](react/react#22477)) //<Brian Vaughn>//
- **[55d7500](react/react@55d75005b )**: duplicate value in variable ([#22390](react/react#22390)) //<BIKI DAS>//

Changelog:
[General][Changed] - React Native sync for revisions afcb9cd...3fcd81d

jest_e2e[run_all_tests]

Reviewed By: yungsters

Differential Revision: D32065987

fbshipit-source-id: ef2d402835c981aab68ca40a894c66c1630864e9
KamranAsif pushed a commit to KamranAsif/react that referenced this pull request Nov 4, 2021
@acdlite @KamranAsif
Replace global jest heuristic with IS_REACT_ACT_ENVIRONMENT (reac…
9e456c6
…t#22562)

* 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.

* 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.
facebook-github-bot pushed a commit to react/react-native that referenced this pull request Nov 15, 2021
Andrei Shikov @facebook-github-bot
React Native sync for revisions afcb9cd...c0c71a8
55663ec
Summary:
This sync includes the following changes:
- **[c0c71a8](react/react@c0c71a868 )**: Re-enable useMutableSource in internal RN ([#22750](react/react#22750)) //<Ricky>//
- **[cb11155](react/react@cb11155c8 )**: Add runtime type checks around module boundary code ([#22748](react/react#22748)) //<Brian Vaughn>//
- **[a04f13d](react/react@a04f13d29 )**: [email protected] //<Dan Abramov>//
- **[ff9897d](react/react@ff9897d23 )**: [React Refresh] support typescript namespace syntax ([#22621](react/react#22621)) //<irinakk>//
- **[0ddd69d](react/react@0ddd69d12 )**: Throw on hydration mismatch and force client rendering if boundary hasn't suspended within concurrent root ([#22629](react/react#22629)) //<salazarm>//
- **[c3f34e4](react/react@c3f34e4be )**: [email protected] //<Dan Abramov>//
- **[827021c](react/react@827021c4e )**: Changelog for [email protected] //<Dan Abramov>//
- **[8ca3f56](react/react@8ca3f567b )**: Fix module-boundary wrappers ([#22688](react/react#22688)) //<Brian Vaughn>//
- **[1bf6deb](react/react@1bf6deb86 )**: Renamed packages/react-devtools-scheduling-profiler to packages/react-devtools-timeline ([#22691](react/react#22691)) //<Brian Vaughn>//
- **[51c558a](react/react@51c558aeb )**: Rename (some) "scheduling profiler" references to "timeline" ([#22690](react/react#22690)) //<Brian Vaughn>//
- **[00ced1e](react/react@00ced1e2b )**: Fix useId in strict mode ([#22681](react/react#22681)) //<Andrew Clark>//
- **[5cccacd](react/react@5cccacd13 )**: Upgrade useId to alpha channel ([#22674](react/react#22674)) //<Andrew Clark>//
- **[75f3dde](react/react@75f3ddebf )**: Remove experimental useOpaqueIdentifier API ([#22672](react/react#22672)) //<Andrew Clark>//
- **[8c4a05b](react/react@8c4a05b8f )**: Remove flow pragma comment from module registration start/stop templates ([#22670](react/react#22670)) //<Brian Vaughn>//
- **[ebf9ae8](react/react@ebf9ae857 )**: useId ([#22644](react/react#22644)) //<Andrew Clark>//
- **[a0d991f](react/react@a0d991fe6 )**: Re-land #22292 (remove uMS from open source build) ([#22664](react/react#22664)) //<Andrew Clark>//
- **[6bce035](react/react@6bce0355c )**: Upgrade useSyncExternalStore to alpha channel ([#22662](react/react#22662)) //<Andrew Clark>//
- **[7034408](react/react@7034408ff )**: Follow-up improvements to error code extraction infra ([#22516](react/react#22516)) //<Andrew Clark>//
- **[90e5d36](react/react@90e5d3638 )**: chore: fix comment typo ([#22615](react/react#22615)) //<btea>//
- **[3c4c1c4](react/react@3c4c1c470 )**: Remove warning for dangling passive effects ([#22609](react/react#22609)) //<Andrew Clark>//
- **[d5b6b4b](react/react@d5b6b4b86 )**: Expand act warning to cover all APIs that might schedule React work ([#22607](react/react#22607)) //<Andrew Clark>//
- **[fa9bea0](react/react@fa9bea0c4 )**: Initial implementation of cache cleanup ([#22510](react/react#22510)) //<Joseph Savona>//
- **[0e8a5af](react/react@0e8a5aff3 )**: Scheduling Profiler: Add marks for component effects (mount and unmount) ([#22578](react/react#22578)) //<Brian Vaughn>//
- **[4ba2057](react/react@4ba20579d )**: Scheduling Profiler: De-emphasize React internal frames ([#22588](react/react#22588)) //<Brian Vaughn>//
- **[cdb8a1d](react/react@cdb8a1d19 )**: [Fizz] Add option to inject bootstrapping script tags after the shell is injected ([#22594](react/react#22594)) //<Sebastian Markbåge>//
- **[34e4c97](react/react@34e4c9756 )**: Clear extra nodes if there's a hydration mismatch within a suspense boundary  ([#22592](react/react#22592)) //<Sebastian Markbåge>//
- **[02f4115](react/react@02f411578 )**: Upgrade useInsertionEffect to stable ([#22589](react/react#22589)) //<Andrew Clark>//
- **[2af4a79](react/react@2af4a7933 )**: Hydrate using SuspenseComponent as the parent ([#22582](react/react#22582)) //<Sebastian Markbåge>//
- **[b1acff0](react/react@b1acff0cc )**: Enable cache in test renderer ([#22580](react/react#22580)) //<Joseph Savona>//
- **[996da67](react/react@996da67b2 )**: Replace global `jest` heuristic with `IS_REACT_ACT_ENVIRONMENT` ([#22562](react/react#22562)) //<Andrew Clark>//
- **[163e81c](react/react@163e81c1f )**: Support disabling spurious act warnings with a global environment flag ([#22561](react/react#22561)) //<Andrew Clark>//
- **[23b7dfe](react/react@23b7dfeff )**: Enable scheduling profiler for RN FB profiling builds ([#22566](react/react#22566)) //<Brian Vaughn>//
- **[61455a2](react/react@61455a25b )**: Enable experimental Cache API in www TestRenderer ([#22554](react/react#22554)) //<Joseph Savona>//
- **[7142d11](react/react@7142d110b )**: Bugfix: Nested useOpaqueIdentifier references ([#22553](react/react#22553)) //<Andrew Clark>//
- **[1e247ff](react/react@1e247ff89 )**: Enabled scheduling profiler marks for React Native FB target ([#22544](react/react#22544)) //<Brian Vaughn>//
- **[c16b005](react/react@c16b005f2 )**: Update test and stack frame code to support newer V8 stack formats ([#22477](react/react#22477)) //<Brian Vaughn>//
- **[55d7500](react/react@55d75005b )**: duplicate value in variable ([#22390](react/react#22390)) //<BIKI DAS>//

Changelog:
[General][Changed] - React Native sync for revisions afcb9cd...c0c71a8

jest_e2e[run_all_tests]

Reviewed By: yungsters

Differential Revision: D32395873

fbshipit-source-id: 3afd158f167b1eedcc244e29aba1a2c502d3c9d9
zhengjitf pushed a commit to zhengjitf/react that referenced this pull request Apr 15, 2022
@acdlite @zhengjitf
Replace global jest heuristic with IS_REACT_ACT_ENVIRONMENT (reac…
ae50983
…t#22562)

* 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.

* 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.
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
@acdlite
Replace global jest heuristic with IS_REACT_ACT_ENVIRONMENT (reac…
d939287
…t#22562)

* 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.

* 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.
@coderabbitai coderabbitai Bot mentioned this pull request Jul 28, 2026
feat(usage && billing ): add end-to-end prepaid usage billing boxlite-ai/boxlite#1076
Closed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 8, 2026
fix: add testRender wrapper with renderer cleanup noodle-rest/noodle#149
Merged
6 of 9 tasks
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@acdlite
Replace global jest heuristic with IS_REACT_ACT_ENVIRONMENT (reac…
d026357
…t#22562)

* 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.

* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@eps1lon eps1lon eps1lon left review comments
+2 more reviewers
@salazarm salazarm salazarm approved these changes
@crypt096 crypt096 crypt096 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@acdlite @sizebot @salazarm @eps1lon @crypt096 @facebook-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.