Back to Sinon

spy.calledWithNew

docs/concepts/spies/api/called-with-new.md

22.1.0721 B
Original Source

spy.calledWithNew

Returns true, when the fake, spy or stub was called the new operator.

<<< ../../../.vitepress/tests/docs/spies/api/called-with-new.test.js

<!-- TODO: Commented out until we can make an example --> <!-- Beware that this is inferred based on the value of the `this` object and the spy function's `prototype`, so it may give false positives if you actively return the right kind of object. -->

Resetting calledWithNew to default

You can reset calledWithNew in three different ways: