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

useFakeTimers does not run as expected with node 7.4.0. #3814

Closed
nickjvm opened this issue Jun 13, 2017 · 4 comments
Closed

useFakeTimers does not run as expected with node 7.4.0. #3814

nickjvm opened this issue Jun 13, 2017 · 4 comments

Comments

@nickjvm
Copy link

nickjvm commented Jun 13, 2017

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Timer example tests fail to pass on node v7.4.0

▶ node -v 
v7.4.0

jest-master/examples/timer                                                                                                                                          
▶ npm test -- --no-cache

> @ test /jest-master/examples/timer
> jest "--no-cache"

 FAIL  __tests__/infiniteTimerGame-test.js
  ● schedules a 10-second timer after 1 second

    TypeError: Cannot read property 'calls' of undefined
      
      at Object.<anonymous> (__tests__/infiniteTimerGame-test.js:15:25)
      at process._tickCallback (internal/process/next_tick.js:103:7)

 FAIL  __tests__/timerGame-test.js
  ● timerGame › waits 1 second before ending the game

    TypeError: Cannot read property 'calls' of undefined
      
      at Object.<anonymous> (__tests__/timerGame-test.js:12:27)
      at process._tickCallback (internal/process/next_tick.js:103:7)

  ● timerGame › calls the callback after 1 second via runAllTimers

    expect(jest.fn()).toBeCalled()
    
    Expected mock function to have been called.
      
      at Object.<anonymous> (__tests__/timerGame-test.js:29:22)
      at process._tickCallback (internal/process/next_tick.js:103:7)

  ● timerGame › calls the callback after 1 second via runTimersToTime

    expect(jest.fn()).toBeCalled()
    
    Expected mock function to have been called.
      
      at Object.<anonymous> (__tests__/timerGame-test.js:46:22)
      at process._tickCallback (internal/process/next_tick.js:103:7)

Test Suites: 2 failed, 2 total
Tests:       4 failed, 4 total
Snapshots:   0 total
Time:        2.117s
Ran all test suites.
npm ERR! Test failed.  See above for more details.

What is the expected behavior?
Expect example tests to pass on Node 7.4.0. After upgrading to Node 7.6.0, timers run and tests pass as expected.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
Fresh npm install from https://github.com/facebook/jest/tree/master/examples/timer

▶ node -v
v7.4.0
▶ npm -v
4.0.5

OS X 10.11.6

The example tests successfully passed with node 7.4.0 and jest 19.0.2. It appears to be an issue with Jest 20.

@rogeliog
Copy link
Contributor

For some reason when I call useFakeTimers twice, the example work 😕
screen shot 2017-06-19 at 9 40 11 am

@rogeliog
Copy link
Contributor

rogeliog commented Jun 19, 2017

I think the issue was introduced in Jest 20... I ran the example with Jest 19 and it seems to work... cc @DmitriiAbramov

@thymikee
Copy link
Collaborator

I think it's specific to Node 7.4, works on every other Node version.

@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 May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants