[expect] Fix .any() checks on primitive wrapper classes - #11976
Merged
SimenB merged 3 commits intoOct 19, 2021
Merged
Conversation
instanceof checks to primitives missing them in .any()
instanceof checks to primitives missing them in .any().any() checks on primitive wrapper classes
Codecov Report
@@ Coverage Diff @@
## main #11976 +/- ##
=======================================
Coverage 68.74% 68.74%
=======================================
Files 323 323
Lines 16649 16649
Branches 4805 4808 +3
=======================================
Hits 11445 11445
Misses 5171 5171
Partials 33 33
Continue to review full report at Codecov.
|
Member
lobsterkatie
deleted the
kmclb-make-any-match-missing-primitive-wrappers
branch
October 19, 2021 13:02
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Currently, the
.any()matcher correctly detects instances of the wrapper classes for numbers and strings:which makes those tests equivalent to the following
instanceoftests (which they should be):At the moment, though, the same cannot be said for instances of the wrapper classes for booleans, symbols, and bigints (even though the corresponding
instanceoftests correctly pass):(Note: The
Object(...)syntax is necessary because neither symbols nor bigints are constructible, and therefore don't work with thenewkeyword.)This is because in the
any()matcher, there areinstanceofchecks for strings and numbers, but not the other primitives: https://github.com/facebook/jest/blob/a1829e9385bef6b007088a012bc3ceb0fa7867a8/packages/expect/src/asymmetricMatchers.ts#L59-L90This PR fixes that by adding in the missing
instanceofchecks.Test plan
There is a new unit test in the asymetric matcher test file which checks both the currently working cases and the currently broken ones.