Skip to content

Latest commit

History

42 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

testdouble-chai

This is a tiny library that adds .called and .calledWith assertions to chai for use with testdouble.js. These assertions can be used as syntactic sugar over the testdouble.verify function. Here are some examples:

Use

it("can tell you if a testdouble object was called",function(){vartd=testdouble.function();td();expect(td).to.have.been.called;// instead of `verify(td)`!});

or with arguments:

it("can tell you if a testdouble object was called a certain way",function(){vartd=testdouble.function();td("hi");expect(td).to.have.been.calledWith("hi");// instead of `verify(td("hi"))`!});

Setup

After installing the library with npm install --save-dev testdouble-chai, here's how to get chai to know about testdouble-chai:

// at the top of a test file or in a test helpervartd=require("testdouble");varchai=require("chai");vartdChai=require("testdouble-chai");chai.use(tdChai(td));// make sure to call tdChai with td to inject the dependency

And you should be good to go! Check out test/testdouble-chai_test.js for an exhaustive description of how this library behaves.

About

Chai assertions for testdouble.js

Resources

Stars

18 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages