如何扩展'应该'库

时间:2013-08-29 10:38:01

标签: javascript node.js coffeescript mocha should.js

我想介绍一下应该断言库,为我的node.js应用程序的测试工作,我的附加功能。

伪代码

这样的东西
should      = require "should"

myExists = (obj, msg) ->
  # my special exist logic

containSomething = (obj, msg) ->
  # my special assert logic

should.myExists = myExists
should.containSomething = containSomething


describe.only "`my extra `", ->
   it 'should be working', (done) ->
     obj = {}
     obj.should.myExists  
     obj.should.not.myExists  
     obj.should.containSomething {cool:obj}
     obj.should.not.containSomething {cool:obj}
     done()

有什么建议在实践中如何做到这一点?

1 个答案:

答案 0 :(得分:0)

should.myExits = myExists

应该是

should.myExist = myExists