简体   繁体   中英

assert.that is. not working in coffee-script

In my iced-coffee-script test I want to check that something is less than expected. The only library I found for this is assertthat :

assert = require 'node-assertthat'
assert.that (actualSeconds, is.atMost (expectedSeconds))

But my code cannot be compiled from iced-coffee-script to js :

error: unexpected ,
    assert.that (actualSeconds, is.atMost (expectedSeconds))

I guess it is because of is , that is key word in coffee-script . Yes, I know I can use assert.ok

assert = require 'assert'
assert.ok actualSeconds <= expectedSeconds

But in this case it don't show seconds on fail. It only show: fail: false == true

So how check that something is less than expected in iced-coffee-script test

Even if I don't like to write pure js , I decided to create one module:

var assert = require ('node-assertthat')
module.exports = function (actual, expected) {
    assert.that (actual, is.atMost(expected))
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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