-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connections property deprecated error. #38
Comments
Can you give a small reproducible code snippet, with no external libraries except Chai, Sinon, and Sinon-Chai, that I can run on my own computer? |
It appears that I can't give you that without externals. I just checked and it seems to be something to do with running requests through express, but I'll give you something as small as I can. |
Yes, it sounds very likely you are triggering some issue with a third-party library, and not a bug in Sinon-Chai. |
Any ideas on which module could be triggering the issue would be great! |
It looks like an issue with Express's |
I might be misunderstanding that Stack Overflow page, but commenting out the call to What am I missing? |
And why would changing the assertion to |
I don't really know the answers to these questions. I'd suggest getting a debugger out and placing a breakpoint where that message is logged, and you can then trace the call stack to find who is responsible for it. |
The In this specific case, that's causing a deep enumeration of the request and response arguments. A response argument will eventually deep enumerate to a So this would be a problem with any
I'm a bit confused as to why it's using the I'm going to send a pull request to have the |
Closing in favor of the pull request. |
So, the reasoning behind those error strings is that we are copying Sinon: https://github.com/cjohansen/Sinon.JS/blob/master/lib/sinon/assert.js#L171-L190 I think the issue is that we are calculating the messages ahead of time, even if the assertion fails. I am not sure whether we can fix this, given how Chai works. But I am pretty sure that if your vanilla-Sinon assertion fails, it will calculate the same error message, and thus cause the same deprecation notice to be printed. That said, it would be nice to fix this to only calculate the error messages on failure. I wonder if we can think of a way to do that... |
I tried down that route a little, but didn't get very far before deciding it would require some pretty big changes (potentially to Sinon as well). The reason I was hoping to get it fixed was because if all tests pass, I don't really want to see the warning. It's a little concerning. It's not the end of the world, though. |
I think there might be a way. For example, we could check to see if the test will pass, and if so, don't pass any message to Chai. This gets a bit tricky with the "not" cases, which is what Chai's assert was supposed to take care of for us, but could still work. Alternately, we could pull-request Chai to allow functions for the messages, so that if the message is a function instead of a string, it evaluates it when it's time to print. That would also allow lazy message determination. |
Sounds good. I'll take a look if I find some time, but it's not a huge priority (and I wouldn't imagine it is for you either). |
@domenic awesome, thanks! |
I'm getting the following error:
connections property is deprecated. Use getConnections() method
when usingcalledOnce
,calledTwice
, etc.It doesn't happen when using
expect(spy.callCount).to.eql(1)
.The text was updated successfully, but these errors were encountered: