Skip to content

Breaking change in 10.0.1: config.target is no longer supported #2352

@kevinoid

Description

@kevinoid

Describe the bug
With [email protected], if options contains target, sinon.useFakeTimers throws a TypeError. This did not occur with [email protected].

To Reproduce

Create index.js with the following content:

const sinon = require('sinon');
sinon.useFakeTimers({ target: { Date } });

Run node index.js after npm install [email protected] and after npm install [email protected]. After installing [email protected] 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions