chai-spies-decorators

0.0.7 • Public • Published

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).

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.7
    1
    • latest

Version History

Package Sidebar

Install

npm i chai-spies-decorators

Weekly Downloads

1

Version

0.0.7

License

Unlicense

Last publish

Collaborators

  • x84
  • xpl