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

fix: ensure browser environment in test-utils #712

Merged
merged 4 commits into from
Dec 30, 2024
Merged

Conversation

thebuilder
Copy link
Owner

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

stackblitz bot commented Dec 30, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

vercel bot commented Dec 30, 2024

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

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

commit: 120c483

@thebuilder thebuilder merged commit f3213dd into main Dec 30, 2024
15 checks passed
@thebuilder thebuilder deleted the fix/test-utils branch December 30, 2024 21:39
@thebuilder
Copy link
Owner Author

🎉 This PR is included in version 9.14.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant