简体   繁体   中英

How to extend 'should' library

I would like o introduce to should assert library, working for tests of my node.js app, my additional functions.

Something like in this pseudocode

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

Any suggestions how to do that in practice?

should.myExits = myExists

应该是

should.myExist = myExists

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM