Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including sinon-expect with all npm packages installed. Try it out:

var sinonExpect = require("sinon-expect")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

sinon-expect v0.3.0

Expect matchers for sinon

Sinon Expect

Sinon expect is a wrapper for the assertions built into sinon.

A quick example is:

var object = {
  method: function(){}

//Yes we are overriding expect
//You can also save it to another variable but that is ugly
expect = require('sinon-expect').enhance(expect, sinon, 'was');

sinon.spy(object, 'method');

//Assert style

//Expect style
//All assertions are found under the .spy namespace/"flag"

List Of Supported Assertions/Matchers

See Sinon Assertions for additional documentation for each of these assertions.

Drop the first argument (the spy) otherwise the method signature is the same.

  • notCalled
  • called
  • calledOnce
  • calledTwice
  • calledThrice
  • callCount
  • callOrder
  • calledOn
  • alwaysCalledOn
  • calledWith
  • alwaysCalledWith
  • neverCalledWith
  • calledWithExactly
  • alwaysCalledWithExactly
  • threw
  • alwaysThrew




RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free