Back to Sinon

assert.notCalled

docs/concepts/assertions/api/not-called.md

22.1.0535 B
Original Source

assert.notCalled(spy);

Passes, when the fake, spy or stub has not been called.

js
import * as sinon from "sinon";
const spy = sinon.spy();

// No exception!
sinon.assert.notCalled(spy);

spy();
sinon.assert.notCalled(spy);
// => Uncaught Error [AssertError]: expected spy to not have been called but was called once

Example using test framework

<<< ../../../.vitepress/tests/docs/assertions/api/not-called.test.js