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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

jest.useFakeTimers("modern") overrides performance object #11330

Closed
Smrtnyk opened this issue Apr 21, 2021 · 2 comments
Closed

jest.useFakeTimers("modern") overrides performance object #11330

Smrtnyk opened this issue Apr 21, 2021 · 2 comments

Comments

@Smrtnyk
Copy link

Smrtnyk commented Apr 21, 2021

馃悰 Bug Report

in setupFilesAfterEnv I have added a timing object to window.performance because I have a logic that relies on those values

When I use jest.useFakeTimers("modern") performance object is overriden and timing object does not exist on it anymore

I could do the initialization logic first and then activate jest.useFakeTimers("modern") but my init logic is a bit complex and it saves references to setTimeout and some other stuff which would result in original setTimeout called when I defer something in my logic and not the faked ones.

To Reproduce

Steps to reproduce the behavior:

Assign some value to performance.timing.
Call jest.useFakeTimers("modern").
Do some logic with performance.timing

Expected behavior

I would expect to still see the timing object as that is what I prepared in my setupFilesAfterEnv file.

envinfo

System:
OS: Windows 10 10.0.19042
CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Binaries:
Node: 14.15.1 - C:\Program Files\nodejs\node.EXE
npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD
npmPackages:
jest: 26.6.3 => 26.6.3

@SimenB
Copy link
Member

SimenB commented Apr 22, 2021

@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 23, 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

2 participants