-
Notifications
You must be signed in to change notification settings - Fork 29
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
Is there a way to verify the order of functions? #55
Comments
I'm not aware of a way to do that with chai-spies. Might want to check out Sinon's |
I think we could consider implementing something similar to |
While I feel like this is a fine feature to add, I have a broader concern about this plugin. What is the long-term goal here? The README says:
Although Thoughts? |
I personally have no long term goal for chai-spies. I think as and when people want features we can consider them. But if you'd like to formulate a more concrete goal then I'd be happy to hear some ideas.
I don't want this to sound rude - but it's a little hard to convey it with text: If you don't want to work on chai-spies, don't! I don't want to dictate a hard structure for what people are going to work on and what they're not. We can set goals and if people agree on that direction, great. I would be horrified to find out a maintainer of any of the chai projects feels a sense of duty to do work they don't want to. It should be a scratch-your-own-itch kind of thing. Personally I use chai-spies over sinon, because it's a simpler, smaller codebase and I can manage that easier, therefore I am happy to spend my time on it. I hope everyone who comments and writes code for it feels the same way. |
I contribute out of enjoyment not obligation. Definitely not my intention to suggest otherwise or establish a negative tone. I'll blame it on poor wording of my final sentence in my previous post :D I'll gather my thoughts on chai-spies and present them in a seperate post so as not to derail this topic any further! |
Any news on this? Just to know what I really need is a way to check that a single spy gets called multiple times with an ordered list of parameter, eg:
I'll see if I can find a reasonable way to add an assertion like |
@teone we still need to hash out some requirements before we discuss an implementation. It seems as though @henriksjostrom's original posting suggests they want to have some kind of global registry of all spy calls to determine an order in which any spy gets called, e.g: const spyA = chai.spy();
const spyB = chai.spy();
const spyC = chai.spy();
spyA();
spyB();
spyC();
expect(spyA).to.be.called.before(spyB).and.before(spyC);
expect(spyB).to.be.called.before(spyC).but.called.after(spyA);
expect(spyC).to.be.called.after(spyB).and.called.after(spyA); It seems what you're suggesting is slightly different: my interpretation (please correct me if I'm wrong) is that you'd like to tell when a particular spy has been called with a set of arguments. So for example: const spy = chai.spy();
spy('a');
spy('b');
spy('c');
expect(spy).to.first.be.called.with('a');
expect(spy).to.second.be.called.with('b');
expect(spy).to.third.be.called.with('c'); These are to different features, both valid, but if you'd like the latter - we should raise a separate issue for it, so we can discuss that one too 😄 |
Yes, you're right, I'll move the discussion in another issue. |
Since sandboxes are now supported this should not be too hard. Right? 😁 |
Suppose I have a setup such that
a()
.then(b)
.then(c)
Is there a way to verify that b runs before c using chai-spies?
The text was updated successfully, but these errors were encountered: