Question

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???

Was it helpful?

Solution

It looks like the functions that weren't matching were functions that had properties added to them. Something like:

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

I ended up changing the way I was testing these anyway, but I thought it would be worth explaining the issue for anyone else who happened upon it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top