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

[Bug]: faketimers not restore when use resetAllMocks and restoreAllMocks #12803

Closed
lmk123 opened this issue May 3, 2022 · 16 comments
Closed

Comments

@lmk123
Copy link

lmk123 commented May 3, 2022

Version

28.0.3

Steps to reproduce

beforeEach(() => {
  jest.resetAllMocks()
  jest.restoreAllMocks()
})

test('1', () => {
  jest.useFakeTimers()
  jest.spyOn(global, 'setTimeout')
  jest.useRealTimers()
})

test('2', (done) => {
  setTimeout(done)
})
  1. or clone these code at https://github.com/lmk123/jest-faketimers-bug
  2. npm install
  3. npm run test
  4. You should see the error come up

Expected behavior

tests all pass

Actual behavior

the second test time out: Exceeded timeout of 5000 ms for a test.

Additional context

jest v27.5.1 has the same error

Environment

System:
    OS: macOS 12.3.1
    CPU: (8) arm64 Apple M1
  Binaries:
    Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
    Yarn: 1.22.18 - /opt/homebrew/bin/yarn
    npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
  npmPackages:
    jest: ^28.0.3 => 28.0.3
@github-actions
Copy link

github-actions bot commented Jun 2, 2022

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added Stale and removed Stale labels Jun 2, 2022
@github-actions
Copy link

github-actions bot commented Jul 3, 2022

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added Stale and removed Stale labels Jul 3, 2022
@github-actions
Copy link

github-actions bot commented Aug 2, 2022

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added Stale and removed Stale labels Aug 2, 2022
@github-actions
Copy link

github-actions bot commented Sep 1, 2022

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added Stale and removed Stale labels Sep 1, 2022
@github-actions
Copy link

github-actions bot commented Oct 1, 2022

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added Stale and removed Stale labels Oct 1, 2022
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added Stale and removed Stale labels Oct 31, 2022
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added Stale and removed Stale labels Nov 30, 2022
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added Stale and removed Stale labels Dec 30, 2022
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Jan 30, 2023
@github-actions github-actions bot removed the Stale label Feb 20, 2023
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added Stale and removed Stale labels Mar 22, 2023
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label May 22, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 21, 2023
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
@lmk123 and others