Skip to content

Fake timers don't work for performance.now() #4004

@satelllte

Description

@satelllte

Describe the bug

Hi 👋

I'm not sure if this a bug or not, but I noticed that Vitest fake timers don't work with High precision timing Web API, specifically for performance.now().

Is it possible to support it?

Reproduction

Code snippet:

satelllte/adsr#46

Stdout example:

> npm run test -- fakeTimers.test.ts

stdout | fakeTimers.test.ts > fake timers > works for performance.now?
(before) performance.now() [1] |  1802.5662189722061
(before) performance.now() [2] |  1803.9706729650497
(before) performance.now() [3] |  1804.0636450052261
(after) performance.now() [1] |  1804.601235985756
(after) performance.now() [2] |  1804.7059119939804
(after) performance.now() [3] |  1804.8976829051971

System Info

System:
    OS: macOS 13.4.1
    CPU: (8) x64 Intel(R) Core(TM) i7-8557U CPU @ 1.70GHz
    Memory: 151.96 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.1 - ~/.nvm/versions/node/v18.16.1/bin/node
    npm: 9.5.1 - ~/.nvm/versions/node/v18.16.1/bin/npm
  Browsers:
    Chrome: 116.0.5845.96
    Chrome Canary: 118.0.5963.0
    Safari: 16.5.2
  npmPackages:
    vitest: 0.34.1 => 0.34.1

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p1-choreDoesn't change code behavior (priority)

    Type

    No type

    Projects

    Status

    Approved

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions