在我的 iced-coffee-script
测试中,我想检查某些内容是否低于预期。
我为此找到的唯一库是 assertthat :
assert = require 'node-assertthat'
assert.that (actualSeconds, is.atMost (expectedSeconds))
但是我的代码无法从 iced-coffee-script
编译为 js
:
error: unexpected ,
assert.that (actualSeconds, is.atMost (expectedSeconds))
我猜这是因为is
,这是coffee-script
中的关键词。
是的,我知道我可以使用 assert.ok
assert = require 'assert'
assert.ok actualSeconds <= expectedSeconds
但在这种情况下,它不会显示失败秒数。它只显示:fail: false == true
那么如何检查iced-coffee-script
测试中的某些内容是否低于预期
最佳答案
即使我不喜欢编写纯 js
,我还是决定创建一个模块:
var assert = require ('node-assertthat')
module.exports = function (actual, expected) {
assert.that (actual, is.atMost(expected))
}
关于node.js - 断言。也就是说。不适用于 CoffeeScript ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18777616/