【发布时间】:2013-02-09 21:57:36
【问题描述】:
我想在我用 Coffeescript 编写的 Node.js 项目中将 should.js 和 mocha 一起使用。
在纯 Javascript 中,should.js 中的表达式类似于
(function(){
throw new Error('fail');
}).should.throw();
现在我想在 Coffeescript 中编写相同的表达式。类似的东西
object.function().should.throw
但是编译成
object["function"]().should["throw"];
我的 Coffescript 代码哪里出错了?
【问题讨论】:
-
object.function来自哪里?为什么叫它? -
这只是一个占位符。我使用的代码是
testModel = new DBModel() testModel.get().should.throw()
标签: javascript node.js coffeescript should.js