-
Notifications
You must be signed in to change notification settings - Fork 359
chore(clerk-js): Refactor snapshot tests #6094
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
Conversation
🦋 Changeset detectedLatest commit: 53e504b The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📝 WalkthroughWalkthroughThis change replaces all snapshot-based test assertions in resource-related test files with explicit, structured assertions. The updated tests now verify object shapes, property values, and types directly using Changes
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (12)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
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.
Pull Request Overview
This PR replaces brittle full-object Jest snapshots with targeted object matching assertions for clearer, more resilient tests.
- Removed generated snapshot files under
__snapshots__
- Updated individual tests to use
toMatchObject
/toEqual
with explicit property checks - Introduced an (empty) changeset file for future release tracking
Reviewed Changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
packages/clerk-js/src/core/resources/tests/snapshots/PublicUserData.test.ts.snap | Removed full snapshot export |
packages/clerk-js/src/core/resources/tests/snapshots/OrganizationSuggestion.test.ts.snap | Removed full snapshot export |
packages/clerk-js/src/core/resources/tests/snapshots/OrganizationMembershipRequest.test.ts.snap | Removed full snapshot export |
packages/clerk-js/src/core/resources/tests/snapshots/OrganizationMembership.test.ts.snap | Removed full snapshot export |
packages/clerk-js/src/core/resources/tests/snapshots/OrganizationInvitation.test.ts.snap | Removed full snapshot export |
packages/clerk-js/src/core/resources/tests/snapshots/OrganizationDomain.test.ts.snap | Removed full snapshot export |
packages/clerk-js/src/core/resources/tests/snapshots/Organization.test.ts.snap | Removed full snapshot export |
packages/clerk-js/src/core/resources/tests/Waitlist.test.ts | Switched from toMatchSnapshot to toMatchObject |
packages/clerk-js/src/core/resources/tests/UserSettings.test.ts | Switched from toMatchSnapshot to toMatchObject |
packages/clerk-js/src/core/resources/tests/Session.test.ts | Switched from toMatchSnapshot to toEqual |
packages/clerk-js/src/core/resources/tests/PublicUserData.test.ts | Switched from string snapshot to toEqual |
packages/clerk-js/src/core/resources/tests/OrganizationSuggestion.test.ts | Switched from toMatchSnapshot to toMatchObject |
packages/clerk-js/src/core/resources/tests/OrganizationMembershipRequest.test.ts | Switched from toMatchSnapshot to toMatchObject |
packages/clerk-js/src/core/resources/tests/OrganizationMembership.test.ts | Switched from toMatchSnapshot to toMatchObject |
packages/clerk-js/src/core/resources/tests/OrganizationInvitation.test.ts | Switched from toMatchSnapshot to toMatchObject |
packages/clerk-js/src/core/resources/tests/OrganizationDomain.test.ts | Switched from toMatchSnapshot to toMatchObject |
packages/clerk-js/src/core/resources/tests/Organization.test.ts | Switched from toMatchSnapshot to toMatchObject |
packages/clerk-js/src/core/resources/tests/Environment.test.ts | Switched from toMatchSnapshot to toMatchObject |
packages/clerk-js/src/core/resources/tests/Client.test.ts | Switched from toMatchSnapshot to toMatchObject |
.changeset/gentle-crews-warn.md | Added empty changeset file |
Comments suppressed due to low confidence (2)
.changeset/gentle-crews-warn.md:1
- The changeset file is empty; please add a summary of the refactoring changes to ensure proper release notes generation.
+---
packages/clerk-js/src/core/resources/tests/Session.test.ts:50
- The test asserts only the first dispatch call; consider adding an assertion for dispatchSpy.mock.calls[1] to maintain coverage of both emitted events.
expect(dispatchSpy.mock.calls[0]).toEqual([
packages/clerk-js/src/core/resources/__tests__/PublicUserData.test.ts
Outdated
Show resolved
Hide resolved
…test.ts Co-authored-by: Copilot <[email protected]>
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.
🧹
Description
Updating tests to use .toMatchObject instead of full snapshot comparisons for entire objects. This change improves test clarity and resilience by focusing assertions on only the relevant parts of the object being tested.
Snapshot tests often capture unnecessary details, leading to noisy diffs and fragile tests when object structures change in unrelated ways. By switching to .toMatchObject, we ensure the tests remain meaningful and maintainable, asserting only what’s essential to the behavior under test.
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit
Summary by CodeRabbit