-
Notifications
You must be signed in to change notification settings - Fork 21
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
Feature: Unify comparison logic with matcher support in Sinon projects #29
Comments
That would be very cool indeed. |
This is related to sinonjs/sinon#1764 (comment), where we discuss the responsibilities of I'll try to do some analysis of this and make a proposal for a way forward that can address most of these. |
@mantoni I've opened sinonjs/sinon#1853 to fix a problem with cyclic objects and If we can get this merged, then I think we'll have a better starting point for future improvements |
I took a stab at consolidating the
To verify
Thoughts
What are your thoughts @mantoni? |
This looks very good, thank you! Here are my thoughts so far:
var fake = sinon.fake()
(function () { fake(arguments) })(1, 2, 3)
sinon.assert.calledWith(fake, [1, 2, 3]) // fails
sinon.assert.calledWith(fake, { 0: 1, 1: 2, 2: 3 }) // also fails, so cannot verify
samsam.deepEqual(fake.firstCall.args[0], [1, 2, 3]) // true
The difficult part will be to get |
I've added sinonjs/samsam#33, which makes it easier to further improve |
I think we will want to keep
From https://github.com/sinonjs/referee/blob/master/docs/index.md#equals If you agree that this is the desired state, then I'll to further improve |
Time for a mono-repo? |
Yes, I agree with the "mission statement" for
Please no. We'd force the code, tooling and tests of |
Let me summarise my current understanding, so we can see if you have the same understanding
Is that roughly your understanding too? |
Yes, we have the same goal in mind. I though the path there would mean to essentially replace the internal |
ok, then I think we have the same understanding. A rough outline of the plan could be:
We should probably expand the documentation for |
I had a look at extracting In order to extract
Instead of having drifting implementations of these (and other useful functions) I'd be ok with having a
I think we can do this, while still avoiding creating another meta package like https://github.com/busterjs/buster#core-modules-in-alphabetical-order If you're happy with that approach, then I'll extract exactly those functions into a new repo and prepare a release that we can then wire back into |
That sounds like a decent plan. I like the strict set of rules you suggested. I don’t know about property based testing and jsverify yet, so there’s something new for me to learn. Let’s do it this way 🙂 |
I've started working on this: sinonjs/commons#1 |
I think this proposal is confusing and a bit magical. I find it confusing to assert that something is |
@fearphage Yes, the above example is maybe too reduced. If I wanted to just assert the type of Consider something like this: assert.equals(record, {
id: match.number,
name: "Max",
role: "Developer"
}); |
Motivation:
It would be totally awesome if this was possible:
Suggestion
A newly exposed
match
function could essentially behave likesinon.match
. I think the matchers actually belong insamsam
and thedeepEqual
logic insamsam
andsinon
should be unified with matcher support. This waysinon
,@sinonjs/referee
and@sinonjs/referee-sinon
can expose it and have the same semantics everywhere.It would then be possible to pass the result of calling
match({ some: 42 })
to both,assert.equals
andspy.calledWith
.The text was updated successfully, but these errors were encountered: