How to extend 'should' library

192 views Asked by At

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?

1

There are 1 answers

1
Ben McCormick On
should.myExits = myExists

should probably be

should.myExist = myExists