Back to Sinon

assert.called

docs/concepts/assertions/api/called.md

22.1.0538 B
Original Source

assert.called(spy);

Passes, when the fake, spy or stub was called at least once.

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

sinon.assert.called(spy);
// => Error [AssertError]: expected spy to have been called at least once but was never called

spy();
// Generates no exception
sinon.assert.called(spy);

Example using test framework

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