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

[PM-16917] Remove jest-extended dependency #12798

Merged
merged 11 commits into from
Jan 15, 2025

Conversation

eliykat
Copy link
Member

@eliykat eliykat commented Jan 10, 2025

🎟️ 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 as expect().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

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 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

@eliykat eliykat requested a review from Hinton January 10, 2025 04:07
@eliykat eliykat requested review from a team as code owners January 10, 2025 04:07
@eliykat eliykat requested review from JimmyVo16 and Jingo88 January 10, 2025 04:07
Copy link
Contributor

github-actions bot commented Jan 10, 2025

Logo
Checkmarx One – Scan Summary & Details71e74d59-6126-48df-8a7e-944a13a6e9d8

New Issues (3)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/org-at-risk-apps-dialog.component.html: 15
detailsMethod org_at_risk_apps_dialog_component at line 15 of /bitwarden_license/bit-web/src/app/tools/access-intelligence/org-at-risk-apps-dialog.compone...
Attack Vector
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/all-applications.component.html: 97
detailsMethod all_applications_component at line 97 of /bitwarden_license/bit-web/src/app/tools/access-intelligence/all-applications.component.html sends ...
Attack Vector
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/all-applications.component.html: 92
detailsMethod all_applications_component at line 92 of /bitwarden_license/bit-web/src/app/tools/access-intelligence/all-applications.component.html sends ...
Attack Vector
Fixed Issues (1)

Great job! The following issues were fixed in this Pull Request

Severity Issue Source File / Package
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/org-at-risk-apps-dialog.component.html: 15

audreyality

This comment was marked as resolved.

@JimmyVo16
Copy link
Contributor

This is essentially approved. I'll revisit it once the pipeline passes.

Copy link

codecov bot commented Jan 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 34.28%. Comparing base (553d20f) to head (03f5066).
Report is 8 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #12798   +/-   ##
=======================================
  Coverage   34.28%   34.28%           
=======================================
  Files        2935     2935           
  Lines       90229    90229           
  Branches    16943    16943           
=======================================
  Hits        30937    30937           
  Misses      56828    56828           
  Partials     2464     2464           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@eliykat
Copy link
Member Author

eliykat commented Jan 13, 2025

I've fixed the failing tests, there were a few places that were still using jest-extended matches that I missed. The change was mostly toHaveBeenCalledOnce() -> toHaveBeenCalledTimes(1). I'm not convinced the syntactic sugar is super useful there, if people want it we could write our own matcher for it fairly trivially, but I assume devs were just using what intellisense was suggesting.

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 (expect().not.toContainPartialObjects) cases.

@eliykat eliykat requested a review from Hinton January 13, 2025 03:34
@eliykat eliykat requested a review from audreyality January 15, 2025 00:03
@eliykat eliykat enabled auto-merge (squash) January 15, 2025 00:04
@eliykat eliykat merged commit 8c13ea8 into main Jan 15, 2025
84 checks passed
@eliykat eliykat deleted the ac/pm-16917/remove-jest-extended-dependency branch January 15, 2025 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants