-
-
Notifications
You must be signed in to change notification settings - Fork 771
Closed
Description
Describe the bug
With sinon@10.0.1
, if options
contains target
, sinon.useFakeTimers
throws a TypeError
. This did not occur with sinon@10.0.0
.
To Reproduce
Create index.js
with the following content:
const sinon = require('sinon');
sinon.useFakeTimers({ target: { Date } });
Run node index.js
after npm install sinon@10.0.0
and after npm install sinon@10.0.1
. After installing sinon@10.0.1
the following error is printed:
/path/to/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js:1299
throw new TypeError(
^
TypeError: config.target is no longer supported. Use `withGlobal(target)` instead.
at Object.install (/path/to/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js:1299:19)
at createClock (/path/to/node_modules/sinon/lib/sinon/util/fake-timers.js:12:31)
at exports.useFakeTimers (/path/to/node_modules/sinon/lib/sinon/util/fake-timers.js:54:16)
at Sandbox.useFakeTimers (/path/to/node_modules/sinon/lib/sinon/sandbox.js:396:46)
at Object.<anonymous> (/path/to/index.js:2:7)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
Expected behavior
No exception would occur.
Additional context
The problem was introduced by f838d78 which bumped @sinonjs/fake-timers
from ^6.0.1
to ^7.0.4
which includes sinonjs/fake-timers#318.
thebrianchen, fatso83, sofisl, adjerbetian, albertyw and 3 more
Activity
regseb commentedon Apr 8, 2021
I have a problem with sinon@10.0.1 and typescript which is surely related to this issue.
To reproduce, create index.js with the following content:
And execute:
The result is:
fatso83 commentedon Apr 8, 2021
@regseb
we don't maintain those typescript bindings, but ship our own. Ah, sorry, I saw the problem is the fake-timer definitions which we DO maintain. This change needs to be reverted.freelerobot commentedon Apr 8, 2021
Hi thanks for fixing. what's the ETA on this?
We'll pin our version, if it's going to take a few days.
fatso83 commentedon Apr 9, 2021
@nicoleczhu pin your version. no one is paid to do this, so it will be when someone does the work to fix and test this manually. that being said, I think this has a high priority, so it will be looked at soon by someone in @sinonjs/sinon-core
bcoe commentedon Apr 9, 2021
@fatso83 I empathize with the no one is paid to do this argument, as someone who's sunk countless hours into handling CVEs for injection bugs logged against yargs.
But just wanted to make sure you knew about this feature on npm:
npm dist-tag add sinon@10.0.0 latest
☝️ this would get folks unblocked who are broken by
10.0.1
, but doesn't require a hard unpublish of10.0.1
.fix(sinon): use sinonjs__fake-timers rather than alias
fix: temporarily pin sinon at 10.0.0 until this is fixed:
fix: temporarily pin sinon at 10.0.0 (#1252)
15 remaining items