0.0.7 • Published 8 years ago
chai-spies-decorators v0.0.7
chai-spies-decorators
npm install chai-spies-decorators
Provides ES7 decorators interface for chai-spies
, allowing to set execution contracts on class methods in a nice declarative way. Requires Mocha.
import 'chai-spies-decorators'
describe ('example', () => {
it ('works', () => {
const foo = new (class Foo {
@will.have.been.called.with (42).once
bar () { }
@will.have.been.called.twice
zap () { }
})
foo.bar (42)
foo.zap (); foo.zap ()
})
})
How it works
I've written an article on Medium explaining it: Wiring ES7 decorators to Chai Spies for declarative contracts on class methods: A metaprogramming case study.
Warning
It is not very well tested with asynchronous tests. Should work with Promises, but not with done
callback (not implemented).