Skip to content
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

Check constructor equality in .toStrictEqual() #7005

Merged
merged 2 commits into from
Oct 20, 2018

Conversation

ollelauribostrom
Copy link
Contributor

Associated Issue: #6767

Summary

Modified typeEquality to check for constructor equality and not just compare constructor names. This makes .toStrictEqual() no longer treat different classes with the same name as equal.

Test plan

  • Added a test case that verifies that .toStrictEqual() no longer treat different classes with the same name as equal.

@codecov-io
Copy link

codecov-io commented Sep 19, 2018

Codecov Report

Merging #7005 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #7005   +/-   ##
=======================================
  Coverage   66.89%   66.89%           
=======================================
  Files         251      251           
  Lines       10488    10488           
  Branches        4        3    -1     
=======================================
  Hits         7016     7016           
  Misses       3471     3471           
  Partials        1        1
Impacted Files Coverage Δ
packages/expect/src/utils.js 98.16% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 728ca11...6252af6. Read the comment docs.

@SimenB
Copy link
Member

SimenB commented Sep 19, 2018

@emilsjolander mind taking a look?

@ollelauribostrom can you update the changelog?

@ollelauribostrom
Copy link
Contributor Author

@SimenB Changelog updated ✔️

Copy link
Collaborator

@thymikee thymikee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@rickhanlonii rickhanlonii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me, should this go in a minor?

it('does not simply compare constructor names', () => {
expect({
test: new TestClassC(1, 2),
}).not.toStrictEqual({test: new TestClassD(1, 2)});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a test for when constructor.name is equal but the constructors are not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last test case (Line 253, it('does not simply compare constructor names'..) should cover this if I'm not mistaken?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I see it now, thanks!

May be worth adding an expect like:

expect(c.constructor.name).toEqual(d.constructor.name);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added that, should make it a bit more clear

@SimenB
Copy link
Member

SimenB commented Sep 25, 2018

should this go in a minor?

Next release is major, unless anyone wanna be fancy with cherry-picking etc.

@SimenB SimenB merged commit 7dfb468 into jestjs:master Oct 20, 2018
@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants