-
-
Notifications
You must be signed in to change notification settings - Fork 768
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
Called in order considers callCount #1406
Called in order considers callCount #1406
Conversation
Hmm, I spent an hour playing with mochify and phantomjs related configs but I couldn't get it to work. I even tried to run a single test and change the I'll dig deeper into this as soon as I've got more time to, but if any of you can remember any detail that might help me fix this, please let me know. |
Hmm... are you able to make it pass locally? I always found mochify (really it's phantom) to be a bit of a black box with regards to diagnostics. |
Nope, I should've tested that before opening that PR, it was my fault to submit a breaking PR, but since I cannot track down the reason of this I'm now thinking it was a good idea do open this PR in order to get feedback. A funny thing is that if I enable the |
If you run |
@mantoni Just tried to play around with mochify in the last hour and couldn't get it to run tests on any real browsers :( I always end up getting this:
Any ideas on how to solve this and investigate further? |
Ok, so I checked out your branch and ran the tests locally. I found your issue: It's the arrow function in the test case. You have to use If you want your local setup working, check the following:
|
FYI: I'm working on a fix for Phantomic to catch parser errors. It's quite a hack, but I should have something soon. |
Finally! This was a bug I was trying to hunt down for quite some time. Your issue nudged me in the right direction 🙌 If you update phantomic to
🐛 🎉 |
@mantoni that is great news! debugging/finding parsing errors was the main pain point of using mochify/phantomic so far. in truth a big improvement! |
I restarted the Travis job, but it still shows the old behavior. I think the dependencies are cached. Does anybody know how to clear |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test case feels like unexpected behavior. If this feature is useful to someone, could we give it a different/special name perhaps?
s1(); | ||
|
||
assert.exception(function () { | ||
sinon.assert.callOrder(s2, s1, s2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks broken. That is not the order they were called in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, In this test I'm expecting an error because that is not the order those spies are called in.
Basically I'm asserting this feature fails when it should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake for misreading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, buddy
I think it's ready for a merge now.
@fearphage thanks for your review 😄 Since this feature has already been released I'm not sure changing its name would be a good idea (this is my personal opinion). Because it adds effort for people that area already using it and I also think that It denotes exactly what we want to assert on and also does not include the word What does everyone think? Let's gather some more opinions. @mantoni thanks for your help, it's awesome to collaborate with such helpful and hard-working people ❤️ Btw, sorry for the misattention. I'm so used to arrow functions that my brain just goes straight through them. I just fixed this PR. It is now ready to merge if everyone agrees. |
e580963
to
4a144d5
Compare
s1(); | ||
|
||
assert.exception(function () { | ||
sinon.assert.callOrder(s2, s1, s2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake for misreading.
if (arguments.length > 1) { | ||
spies = arguments; | ||
spies = Array.prototype.slice.call(arguments); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MINOR: The only reason to use slice
here would be if you plan to used spies.every(...)
later. However you are using every.call(...)
so you can revert this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fearphage well noticed! I just fixed it.
Thanks for your careful review, this was indeed something that needed to be fixed 👍
@lucasfcosta One small thing, but I think it's good to go after that. |
4a144d5
to
54b5837
Compare
Purpose (TL;DR)
This makes
calledAfter
symetric withcalledBefore
, as I explained in #1398.Background (Problem in detail)
Semantically speaking,
calledAfter
does not do what it says it does.When you say you expect
something
to have beencalledAfter
anotherThing
, you don't care ifsomething
has been called last or not, all you care about is ifsomething
has been called any times afteranotherThing
.This is the way
calledBefore
works. It is not concerned about whether or not the current spy was the first to be called, it just checks if the current spy has been called any times before the passed spy.Solution
I just check if the last call to the current spy (
this
) has happened after the first call to the passed spy (spyFn
) by comparing theircallIds
I also fixed a test which had the incorrect spec for this.
How to verify
npm install
npm test
-> This will run all tests including the modified one with the correct specEDIT: Building is breaking on PhantomJS, I gotta see why. Let me check this...