chai-and-then

1.0.1 • Public • Published

chai-and-then

A simple helper for multiple async assertions. It allows for easy and natural chaining of your assertions, for example to observe side effects.

Instead of using this you would need to use .then, which can make the code harder to read.

Example

This is taken from the tests and shows how easy it is to observe side effects.

describe("a small example", function exampleTest() {
  it("correctly observers side effects", function sideEffects() {
    var target = { count : 0 }
 
    function foo() {
      target.count++
      return true
    }
 
    expect(target).to.have.property("count", 0)
    return expect(Promise.resolve().then(foo)).to.become(true)
      .andThen(target).to.have.property("count", 1)
  })
})

Package Sidebar

Install

npm i chai-and-then

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • max.nordlund