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

Using jest's fake timers completely freezes test execution #83

Open
alucryd opened this issue Jan 30, 2024 · 2 comments
Open

Using jest's fake timers completely freezes test execution #83

alucryd opened this issue Jan 30, 2024 · 2 comments

Comments

@alucryd
Copy link

alucryd commented Jan 30, 2024

Using fake timers in multiple tests freezes the execution, with no other option but to kill the process.

import dayjs from "dayjs";

const now = dayjs();

beforeEach(async () => {
  jest.useFakeTimers().setSystemTime(now.toDate());
})

afterEach(async () => {
  jest.useRealTimers();
})

Calling jest.useRealTimers(); in afterEach as suggested here doesn't help unfortunately. Sorry I took so long go get back to creating a dedicated issue.

@alucryd alucryd changed the title Using jest's fake timers completely freeze test execution Using jest's fake timers completely freezes test execution Jan 30, 2024
@Zikoat
Copy link
Contributor

Zikoat commented Mar 7, 2024

I am investigating a related issue, but i cannot reproduce it with your example. My issue was that some of my code was running which was depending on the time, and the promise never resolved. Could you debug your code to figure out on which line it is stopping? Or even better, create a minimal reproducible example, so we can reproduce it locally, see https://stackoverflow.com/help/minimal-reproducible-example . We would need a whole git repository with configuration and all the files, and the commands to reproduce the freeze.

@Zikoat
Copy link
Contributor

Zikoat commented Mar 7, 2024

You could also try running this with normal jest (not with jest-light-runner) to see if the problem is still present with normal jest.

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

No branches or pull requests

2 participants