-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
.toEqual() #1439
.toEqual() #1439
Conversation
aaronabramov
commented
Aug 16, 2016
As previously discussed,
Alternatively we can run a huge codemod using Jest inside of a jscodeshift transform to codemod the failing tests to a new matcher that matches the current implementation of Another thing I want to bring up is whether you thought about not printing either objects in red. My biggest problem in a sentence like Finally, if you can find the fastest toEqual implementation on the planet and use that, I would be happy. It is the most used matcher by far and we run some pretty huge objects (in ads code) through it. |
I'm confused when it doesn't match what I'd see in a diff on GitHub. i.e. when |
i don't like the also the fact that expect(actual).toEqual(expected) my thoughts on this were to get rid of these terms completely and replace them with: |
I was discussing this with @cpojer and he said something very similar about expected vs. actual. I've never seen this as confusing, but that may just be a privilege of being a native speaker 😄 added/missing sounds like a good idea for diffs. For tests that aren't diff maybe |
Let's have this discussion separately from this diff which is about pretty-printing the values. I care more about changing the colors around so that when printing two objects I can still see whether it says "to equal" or "to be". I can do that in a separate diff. For actual/expected, I think we need to have a bit more of a discussion. I'll think about it. |
I think GH logic doesn’t quite apply there. You’re not really “starting” from the expected value and then changing your app to output the wrong thing. I can imagine that when you start thinking about it, it might feel incorrect, but if you just glance without thinking or if you are drunk, I think “red is bad” feels much more intuitive. |
I think green doesn't have a place in this context. Should be red and white, imo. Red being the erroneous value |
@yaycmyk: in reality there are 3 colours for object diffs:
The debate is which way round the colour coding is. The alternative would be to choose two completely unrelated colours (e.g. yellow and blue) so you avoid having any intuitive expectations. @gaearon I think we may always disagree on this point. The way I see it, especially with snapshot testing, is that the first run of the test creates the snapshot, so every subsequent test should be showing me what's changed from that snapshot. I suspect that if you were to run polls for what the most popular answer is, you could get people to prefer either answer with subtly different wording of the question. |
Oh, I can see how this can be confusing. |
I think that snapshot testing should use diff coloring. This makes total sense because you interpret it as a diff which you can review. red = old However I also think that regular assertions don’t need to be like diffs because most of the time (hopefully) tests will be stable, and regular code will need to be adjusted per tests. So I think this color scheme makes more sense for regular assertions: red = actual I just wanted object diffs (#1439 (comment)) to follow the same convention. |
I'll send a new PR that uses jasmine's toEqual matcher for now and then another PR on top of that to polish all the messages and their colors. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |