-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[PM-16917] Remove jest-extended dependency #12798
base: main
Are you sure you want to change the base?
Conversation
New Issues (2)Checkmarx found the following issues in this Pull Request
Fixed Issues (1)Great job! The following issues were fixed in this Pull Request
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
I'll approve once the failing tests and other reviewers' feedback have been addressed.
) { | ||
const pass = this.equals( | ||
received, | ||
expect.arrayContaining(expected.map((e) => expect.objectContaining(e))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻 TIL about expect.arrayContaining
! I've been doing this the hard way. 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻 Yo dawg! I put a test in your test so you could test your tests...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always! You test your code but who will test the tests??
libs/common/spec/matchers/index.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
♻️ We have enough extensions to jest
now that we might want to consider creating our own spec module (e.g. @bitwarden/jest-extensions
) and updating jest's configurations to load it. (Not in this PR.)
This is essentially approved. I'll revisit it once the pipeline passes. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #12798 +/- ##
==========================================
- Coverage 34.14% 34.13% -0.01%
==========================================
Files 2936 2936
Lines 90435 90435
Branches 16989 16989
==========================================
- Hits 30876 30869 -7
- Misses 57102 57109 +7
Partials 2457 2457 ☔ View full report in Codecov by Sentry. |
I've fixed the failing tests, there were a few places that were still using I also had to tweak the matcher itself to not use a generic signature as this is not supported by the jest type package. EDIT: I've also added more helpful error messages for the positive & negative ( |
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-16917
📔 Objective
@Hinton requested that we reconsider whether we need the
jest-extended
dependency.We only use 2 matchers from it:
tobeTrue()
- trivially rewritten asexpect().toBe(true)
.toIncludeAllPartialMembers
- this checks that all the expected objects appear in the array using a partial match (e.g.objectContaining
). This is useful but was easy enough to implement our own version of.I have made these changes and removed
jest-extended
.Unfortunately I did need to add
jest-diff
to present a readable error message if the custom matcher fails. However, this is already used by jest so it's not net new. Also, it's officially maintained by jest rather than the community. So overall I still think this is an improvement.I made SM Team the owner of
jest-diff
for renovate purposes, just to keep it grouped with the existing configuration for jest packages.📸 Screenshots
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes