Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: ensure browser environment in test-utils#712

Merged
thebuilder merged 4 commits intomainfrom
fix/test-utils
Dec 30, 2024
Merged

fix: ensure browser environment in test-utils#712
thebuilder merged 4 commits intomainfrom
fix/test-utils

Conversation

Copy link
Owner

thebuilder commented Dec 30, 2024

This pull request includes several changes to the src/test-utils.ts file to improve the handling of the React act function and IntersectionObserver mocking. The key changes involve refactoring the code to ensure compatibility with different environments and simplifying the logic.

Refactoring for compatibility and simplification:

  • Removed the global declarations for IS_REACT_ACT_ENVIRONMENT and jest in src/test-utils.ts, so we don't clash with user type definitions.
  • Updated the condition to check for window before setting up IntersectionObserver mocking in src/test-utils.ts.
  • Replaced the getIsReactActEnvironment function with getActFn to encapsulate the logic for determining the appropriate act function in src/test-utils.ts.
  • Modified the triggerIntersection function to use the new getActFn method for invoking the act function in src/test-utils.ts.

Fixes #710 and #711

Copy link

bolt-new-by-stackblitz bot commented Dec 30, 2024

Run & review this pull request in StackBlitz Codeflow.

Copy link

vercel bot commented Dec 30, 2024 *
edited
Loading

The latest updates on your projects. Learn more about Vercel for Git /

Name Status Preview Comments Updated (UTC)
react-intersection-observer Ready (Inspect) Visit Preview Add feedback Dec 30, 2024 9:15pm

Copy link

pkg-pr-new bot commented Dec 30, 2024 *
edited
Loading

npm i https://pkg.pr.new/thebuilder/react-intersection-observer@712

commit: 120c483

vercel bot deployed to Preview December 30, 2024 21:08 View deployment
vercel bot deployed to Preview December 30, 2024 21:11 View deployment
vercel bot deployed to Preview December 30, 2024 21:15 View deployment
thebuilder merged commit f3213dd into main Dec 30, 2024
14 checks passed
thebuilder deleted the fix/test-utils branch December 30, 2024 21:39
Copy link
Owner Author

thebuilder commented Dec 30, 2024

This PR is included in version 9.14.1

The release is available on:

Your semantic-release bot

thebuilder added the released label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Global jest type from test-utils causing issues when existing test files also interact with the global jest object

1 participant