Skip to content

useFakeTimers no longer mocks out timer functions properlyΒ #11447

@jsumnerp

Description

@jsumnerp

πŸ› Bug Report

With the new fakeTimers the setTimeout, setInterval, clearTimeout, clearInterval functions are no longer properly mocked

● waits 1 second before ending the game

expect(received).toHaveBeenCalledTimes(expected)

Matcher error: received value must be a mock or spy function

Received has type:  function
Received has value: [Function anonymous]

To Reproduce

https://jestjs.io/docs/timer-mocks using the first example

Expected behavior

For timer functions to be mocked or docs to be updated to show how to get the same results

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions