我试图让 nodeunit 模块在一个咖啡脚本项目中工作,但似乎连基本的测试都无法运行。这是我的示例 Coffeescript 需要'nodeunit'
test = true
test2 = false
exports.testSomething = (test) ->
test.expect(1)
test.ok(true, "this should pass")
test.done()
exports.testSomethingElse = (test2) ->
test2.expect(1)
test2.ok(false, "this should fail")
test2.done()
不幸的是,当我运行 '$ nodeunit example.coffee' 时,我得到了错误输出:
example.coffee:4 exports.testSomething = (test) -> ^
module.js:296 抛出错误;^ SyntaxError: Unexpected token > at Module._compile (module.js:397:25) at Object..js (module.js:408:10) at Module.load (module.js:334:31) at Function._load (module.js:293:12) 需要 (module.js:346:19) 在 /usr/local/lib/node/nodeunit/lib/nodeunit.js:75:37 在 /usr/local/lib/node /nodeunit/deps/async.js:508:13 在 /usr/local/lib/node/nodeunit/deps/async.js:118:13 在 /usr/local/lib/node/nodeunit/deps/async.js :134:9 在 /usr/local/lib/node/nodeunit/deps/async.js:507:9
任何人都可以帮助我使用 Node.js 在 Coffeescript 中启动和运行一个简化的测试吗?
提前致谢