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: Guard against jest.useRealTimers not existing #934

Merged
merged 2 commits into from
Apr 22, 2021

Conversation

ph-fritsche
Copy link
Member

What:

Check if jest.useRealTimers is a function before calling it.
Closes #905

Why:

In some environments (e.g. codesandbox) jest exists but is either null or the useRealTimers and useFakeTimers don't exist.

Checklist:

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 22, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 80a6af8:

Sandbox Source
react-testing-library-examples Configuration

@codecov
Copy link

codecov bot commented Apr 22, 2021

Codecov Report

Merging #934 (80a6af8) into master (793d598) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #934   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           26        26           
  Lines          948       953    +5     
  Branches       284       289    +5     
=========================================
+ Hits           948       953    +5     
Flag Coverage Δ
node-10.14.2 100.00% <100.00%> (ø)
node-12 100.00% <100.00%> (ø)
node-14 100.00% <100.00%> (ø)
node-16 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/helpers.js 100.00% <100.00%> (ø)

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 793d598...80a6af8. Read the comment docs.

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

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

Looks good. Just one potential ReferenceError slipped through I think.

src/helpers.js Outdated Show resolved Hide resolved
Co-authored-by: Sebastian Silbermann <silbermann.sebastian@gmail.com>
Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

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

Verified this change actually fixes #905 with

diff --git a/package.json b/package.json
index 76ba73e..8ab24e3 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,7 @@
   "license": "Apache License, Version 2.0",
   "type": "module",
   "dependencies": {
-    "@tmtsoftware/esw-ts": "git+https://github.com/tmtsoftware/esw-ts#2a03d094a7439b4f21bd262c10f13d9f2ef76033",
+    "@tmtsoftware/esw-ts": "https://github.com/eps1lon/esw-ts#fad5e14e22ab4e6019bf8a1012906044ec36aa7e",
     "antd": "^4.13.1",
     "react": "^17.0.1",
     "react-dom": "^17.0.1",
@@ -66,5 +66,8 @@
     "stylelint-config-standard": "^21.0.0",
     "ts-mockito": "^2.6.1",
     "typescript": "^4.2.3"
+  },
+  "resolutions": {
+    "**/@testing-library/dom": "https://pkg.csb.dev/testing-library/dom-testing-library/commit/80a6af82/@testing-library/dom"
   }
 }

@eps1lon eps1lon changed the title fix: check if jest.useRealTimers exists fix: Guard against jest.useRealTimers not existing Apr 22, 2021
@eps1lon eps1lon merged commit 1b19094 into testing-library:master Apr 22, 2021
@github-actions
Copy link

🎉 This PR is included in version 7.30.4 🎉

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
Development

Successfully merging this pull request may close these issues.

jest.useRealTimers() is not a function when running RTL tests in jest-electron environment
2 participants