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

Uplift sinon to 19+ #9768

Open
jkuester opened this issue Jan 31, 2025 · 0 comments · May be fixed by #9780
Open

Uplift sinon to 19+ #9768

jkuester opened this issue Jan 31, 2025 · 0 comments · May be fixed by #9780
Labels
Dependencies Update the project's dependencies/libraries Type: Technical issue Improve something that users won't notice

Comments

@jkuester
Copy link
Contributor

Describe the issue
Sinon 19 changed the way useFakeTimes works so that calling that function ends up automatically mocking a bunch of stuff.

In some of our tests, it does not work to have everything mocked (particularly, I have observed issues when mocking nextTick when using @medic/memdown). One solution is to just limit which functions are mocked.

So, you might have original test code that looks like this:

sinon.useFakeTimers(NOW.valueOf());

To fix it, use the toFake option to include only the actual functions that need to be faked for your test.

sinon.useFakeTimers({ now: NOW.valueOf(), toFake: ['Date']});

FTR, here are the list of all the valid function names I know of:

    const clock = sinon.useFakeTimers({ now: NOW.valueOf(), toFake: [
      'setTimeout', 'clearTimeout', 'setInterval', 'clearInterval', 'setImmediate', 'clearImmediate', 'hrtime', 'Date', 'nextTick'
    ]});
@jkuester jkuester added Type: Technical issue Improve something that users won't notice Dependencies Update the project's dependencies/libraries labels Jan 31, 2025
akshat16j added a commit to akshat16j/cht-core that referenced this issue Feb 5, 2025
Uplifted sinon to 19+ and modified the useFakeTimes function.
@jkuester jkuester linked a pull request Feb 5, 2025 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dependencies Update the project's dependencies/libraries Type: Technical issue Improve something that users won't notice
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant