Skip to content

fix(act): add try/catch around react-dom/test-utils require #340

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

Merged
merged 1 commit into from
Apr 1, 2019

Conversation

kentcdodds
Copy link
Member

What: add try/catch around react-dom/test-utils require

Why: Closes #315

How: replace import with require so we can make it happen dynamically

Checklist:

  • Documentation added to the docs site N/A
  • Tests N/A
  • Typescript definitions updated N/A
  • Ready to be merged
  • Added myself to contributors table N/A

@codecov
Copy link

codecov bot commented Apr 1, 2019

Codecov Report

Merging #340 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #340   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           2      2           
  Lines          41     43    +2     
  Branches        7      7           
=====================================
+ Hits           41     43    +2
Impacted Files Coverage Δ
src/act-compat.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6890f4f...66aebc1. Read the comment docs.

@kentcdodds
Copy link
Member Author

If I could get one review that would be stellar 👍


let reactAct
try {
reactAct = require('react-dom/test-utils').act
Copy link
Collaborator

@alexkrolick alexkrolick Apr 1, 2019

Choose a reason for hiding this comment

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

Will this throw if act is not defined but the test-utils package is?

Copy link
Member Author

Choose a reason for hiding this comment

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

No it wont, but we'll handle it fine anyway thanks to the || below 👍

@kentcdodds kentcdodds merged commit 89299e9 into master Apr 1, 2019
@kentcdodds kentcdodds deleted the pr/act-compat-fix branch April 1, 2019 17:33
@kentcdodds
Copy link
Member Author

🎉 This PR is included in version 6.0.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

lucbpz pushed a commit to lucbpz/react-testing-library that referenced this pull request Jul 26, 2020
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants