1

I'm trying to test that an express route is set in my node app using jasmine (along with jasmine-given and jasmine-stealth). I'm doing it in a loop but the gist of the comparison is (in coffeescript, incidentally):

route = app.stack.shift()
expect(route).toEqual
    route: ''
    handle: jasmine.any(Function)

I'm using jasmine.any on this particular test because the handle function comes from an express internal function (like express.static(/*stuff*/)). When I run the tests with grunt, I'm getting get failures with the following message:

Message:
 Expected { route : '', handle : Function } to equal { route : '', handle : Function }.

Those look the same to me. Am I missing something???

4

1 回答 1

1

看起来不匹配的函数是添加了属性的函数。就像是:

var f = function() { . . . }
f.otherFunction = function() {
    console.log("Ha! You'll never know this is here!");
}

无论如何,我最终改变了我测试这些的方式,但我认为值得为遇到它的其他人解释这个问题。

于 2014-01-14T18:24:23.650 回答