-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Jeremy Greer edited this page Sep 8, 2014
·
6 revisions
Willy is an assertion library designed to be simple and readable. It doesn't follow the normal BDD/TDD assertion styles, but reads more like questions.
var will = require('willy').will;
describe('some test suite', function () {
it('should do X, Y, and Z', function () {
// Will it?
will(true).be(true);
});
});
Willy...
- is super easy to use
- includes a bunch of built-in tests
- makes custom tests easy
- supports promises
Keep it simple, so you can focus on your code, not your tests. Compare testing instanceof
in a few different assertion libraries.
// Chai
expect(foo).to.be.an.instanceof(Foo);
// Shouldjs
foo.should.be.an.instanceOf(Foo)
// Jasmine
expect(foo).toEqual(jasmine.any(Foo));
// Willy
will(foo).beA(Foo);
Want to add to Willy's repertoire? That's easy, too.
willy.define(function beASubstringOf() {
return this.expected.indexOf(this.actual) > -1;
});
will('potato').beASubstringOf('Bender Bending Rodriguez');
// expected 'potato' to be a substring of 'Bender Bending Rodriguez'