was called

  • <spy> was called

Passes if spy was called at least once.

var increment = sinon.spy();
increment(42);
expect(increment, 'was called');

In case of a failing expectation you get the following output:

expect(sinon.spy().named('mySpy'), 'was called');
expected mySpy was called

This assertion can be negated using the not flag:

expect(sinon.spy(), 'was not called');

In case of a failing expectation you get the following output:

var add = sinon.spy().named('add');
add(42, 42);
expect(add, 'was not called');
expected add was not called
 
add( 4242 ); at theFunction (theFileName:xx:yy) // should be removed