-
-
Notifications
You must be signed in to change notification settings - Fork 693
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I test for an ordered subset with gaps between the elements? #1056
Comments
@shepmaster I don't think there's a simple way to do that currently. It's very possible that we used the wrong algorithm for In the meantime, your best bet may be to either include the actions you don't care about in the assertion, or filter the array prior to the assertion to only include the ones you care about. |
Thanks!
Without thinking too deeply on it, it seems changing it now would not be a backwards-compatible change; do you agree? We might need to come up with a new name if the new algorithm seems useful...
In this case, I can't easily do that because the actions I'd like to ignore actually have unique IDs in them, which makes it pretty hard to control :-)
That was my second thought as well, but it's a little ugly as I have to dig into the internals of each element to figure out which ones to keep and which to discard. I can certainly do this if there is no better solution we can come up with. |
When Regarding filtering: Don't you just need to know the ones you're keeping, which are the same ones you're testing for? |
Same issue here, albeit not redux. Actual: [ { message: 'fillStyle', args: [ 'transparent' ] },
{ message: 'strokeStyle', args: [ 'black' ] },
{ message: 'strokeStyle', args: [ 'purple' ] },
{ message: 'beginPath', args: [] },
{ message: 'arc', args: [ 140, 100, 50, 0, 6.283185307179586 ] },
{ message: 'stroke', args: [] } ] And we test it like this:
But that doesn't assert on the order. |
I'd be happy if the semantics matched those described in the original comment. It seems to make sense to me 馃憤 |
Hey @shepmaster thanks for the issue. We've added this to our Roadmap https://github.com/chaijs/chai/projects/2! We'll be releasing chai 5 soon, but for now I'll close this issue because it is tracked on our roadmap. |
I have an array of Redux actions, some of which I care about and some which I don't. I do care about the order (an async request had better come before a response! 馃槆 ).
I tried code like this with Chai 4.1.2:
Which yields the error:
Reading through #717, it appears that this was deliberate:
What is the correct syntax to say "element A must come before B, which must come before C, which ..."?
Thanks for the great library!
The text was updated successfully, but these errors were encountered: