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

FakeTimes problem when upgrading jest 25 to 29 #1161

Closed
Okyaaa opened this issue Dec 8, 2022 · 5 comments
Closed

FakeTimes problem when upgrading jest 25 to 29 #1161

Okyaaa opened this issue Dec 8, 2022 · 5 comments

Comments

@Okyaaa
Copy link

Okyaaa commented Dec 8, 2022

Hi, everyone! I have several problems when upgrading jest 25 to 29
(Problem on faketimers)

Installed dependencies

"react": "16.13.1",
"react-dom": "16.13.1",

"@testing-library/react-hooks": "^7.0.2",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "12.1.5",
"@types/jest": "28.1.1",
"@types/react": "^17.0.33",
"jest": "29.2.2",
"jest-environment-jsdom": "^29.2.2",
"jest-junit": "^12.0.0",
"typescript": "4.3"

Jest.config
image

When using fake timers i have to set legacy to true and the advanceTimers going to works, but it's not work in another test
Example :

image
On this code advanceTimers not works fine, at some cases there are a few tests that we need to raise the timeout duration, is there any explanation or something ?

image
If you have any suggestions for my problem, it's going to help me a lot. Thank you

@compulim
Copy link

Same to me.

I tested it against the official sample "Scenario 5: setTimeout" from https://react-testing-library-examples.netlify.app/. It appears the jest.runAllTimers() did not advance the clock.

@yadigarbz
Copy link

My error was,

thrown: "Exceeded timeout of 20000 ms for a hook.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

Configuration

"@testing-library/jest-native": "^5.4.1",
"expo": "~44.0.6",
"react": "17.0.1",
"react-native": "0.64.4",
"jest": "^29.4.1",

But putting jest.useRealTimers() to each test fixed my issue, where we used jest.useFakeTimers() before

@deshiknaves
Copy link

Except using jest.userRealTimers means that now the test takes longer to run.

@eps1lon
Copy link
Member

eps1lon commented Feb 15, 2023

It doesn't look like this bug report has enough info for one of us to reproduce it.

Please provide a CodeSandbox (https://react.new), or a link to a repository on GitHub.

Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve

@eps1lon
Copy link
Member

eps1lon commented May 22, 2023

Closing since no repro was provided.

@eps1lon eps1lon closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants