Automattic / expect.js

Minimalistic BDD-style assertions for Node.JS and the browser.
2.11k stars 209 forks source link

`.which` property #123

Open nathanmacinnes opened 10 years ago

nathanmacinnes commented 10 years ago

This is something I'll find very useful. I've tried to make the tests illustrate the benefit, but in a bit more detail:

expect(fooBar).to.have.property("foo").which.is.an("object")
  .and.has.property("bar").which.is.a("function");

and this is the equivalent without .which:

expect(fooBar).to.have.property("foo");
expect(fooBar.foo).to.be.an("object")
  .and.to.have.property("bar");
expect(fooBar.foo.bar).to.be.a("function");