Javascript 用mocha测试json.parse

Javascript 用mocha测试json.parse,javascript,node.js,mocha.js,Javascript,Node.js,Mocha.js,为什么在使用mocha进行测试时,以下代码没有通过 我的示例模块: module.exports = function(){ JSON.parse("this is not json") } 还有我的test.js: var should = require("should") var module = require("./module") describe("error testing", function(){ it("should throw an error", funct

为什么在使用mocha进行测试时,以下代码没有通过

我的示例模块:

module.exports = function(){
  JSON.parse("this is not json")
}
还有我的test.js:

var should = require("should")
var module = require("./module")

describe("error testing", function(){
  it("should throw an error", function(done){
    module().should.throw();
    done();
  })
})
我希望测试能通过,但运行摩卡给了我以下信息:

✖ 1 of 1 tests failed:

1) error testing should throw an error:
   SyntaxError: Unexpected token h
    at Object.parse (native)
    at module.js:9:8
    at Context.<anonymous> (test.js:6:5)
    at Test.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:145:15)
    at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:270:10)
    at /usr/local/lib/node_modules/mocha/lib/runner.js:314:12
    at next (/usr/local/lib/node_modules/mocha/lib/runner.js:198:14)
    at /usr/local/lib/node_modules/mocha/lib/runner.js:207:7
    at next (/usr/local/lib/node_modules/mocha/lib/runner.js:157:23)
    at Array.0 (/usr/local/lib/node_modules/mocha/lib/runner.js:175:5)
    at EventEmitter._tickCallback (node.js:192:40)
✖ 1次测试中有1次失败:
1) 错误测试应抛出一个错误:
SyntaxError:意外标记h
at Object.parse(本机)
在module.js:9:8
在上下文中。(test.js:6:5)
在Test.run(/usr/local/lib/node_modules/mocha/lib/runnable.js:145:15)
在Runner.runTest(/usr/local/lib/node_modules/mocha/lib/Runner.js:270:10)
at/usr/local/lib/node_modules/mocha/lib/runner.js:314:12
下一步(/usr/local/lib/node_modules/mocha/lib/runner.js:198:14)
at/usr/local/lib/node_modules/mocha/lib/runner.js:207:7
下一步(/usr/local/lib/node_modules/mocha/lib/runner.js:157:23)
在Array.0(/usr/local/lib/node_modules/mocha/lib/runner.js:175:5)
在EventEmitter上进行回调(node.js:192:40)
should.throw()期望对函数调用,而不是对函数的结果调用。更改此项:

module().should.throw();
module.should.throw();
为此: