简体   繁体   English

如何扩展“应该”库

[英]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. 我想介绍一下应该断言库,用于我的node.js应用程序的测试以及其他功能。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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