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

Fake timers are not detected at jest@28 #36

Open
goooseman opened this issue May 22, 2023 · 2 comments · May be fixed by #37
Open

Fake timers are not detected at jest@28 #36

goooseman opened this issue May 22, 2023 · 2 comments · May be fixed by #37

Comments

@goooseman
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/wait-for-expect/lib/helpers.js b/node_modules/wait-for-expect/lib/helpers.js
index 27d63b7..aee6aa4 100644
--- a/node_modules/wait-for-expect/lib/helpers.js
+++ b/node_modules/wait-for-expect/lib/helpers.js
@@ -15,7 +15,9 @@ var globalObj = typeof window === "undefined" ? global : window; // Currently th
 
 function runWithRealTimers(callback) {
   var usingJestFakeTimers = // eslint-disable-next-line no-underscore-dangle
-  globalObj.setTimeout._isMockFunction && typeof jest !== "undefined";
+    typeof jest !== 'undefined' &&
+    setTimeout.clock != null &&
+    typeof setTimeout.clock.Date === 'function';
 
   if (usingJestFakeTimers) {
     jest.useRealTimers();

This issue body was partially generated by patch-package.

@goooseman goooseman reopened this May 22, 2023
@goooseman goooseman linked a pull request May 22, 2023 that will close this issue
@aarowman
Copy link

aarowman commented Sep 1, 2023

+1
I am also having this issue

@aarowman
Copy link

Any updates on this item? It's been over a year :(

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

Successfully merging a pull request may close this issue.

2 participants