Introduce react-intl auto-mock to simplify test maintenance#5935
Introduce react-intl auto-mock to simplify test maintenance#5935lkostrowski merged 26 commits intomainfrom
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the test setup for React Intl by creating a centralized mock configuration and removing duplicated mocks across test files. The main purpose is to simplify test maintenance by consolidating React Intl mocking in a single location.
Key changes:
- Created a global
react-intlmock file to replace individual test mocks - Updated the test utilities to export a pre-configured
testIntlInstance - Removed individual
jest.mock("react-intl")calls from 50+ test files
Reviewed Changes
Copilot reviewed 81 out of 82 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
__mocks__/react-intl.ts |
New global mock for react-intl package with comprehensive function mocking |
testUtils/intl.ts |
Updated to export testIntlInstance instead of intlMock for consistency |
| Multiple test files | Removed redundant react-intl mocks and updated imports to use centralized utilities |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/staff/components/StaffPasswordResetDialog/StaffPasswordResetDialog.test.tsx
Show resolved
Hide resolved
src/extensions/views/InstallCustomExtension/InstallCustomExtension.test.tsx
Show resolved
Hide resolved
src/extensions/views/InstallCustomExtension/InstallCustomExtension.test.tsx
Show resolved
Hide resolved
Updated test to expect {link} placeholder instead of actual gift card values.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Updated test to expect {name} placeholder instead of interpolated value.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Updated test to expect {name} placeholder instead of interpolated value.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Updated test to expect {name} placeholder instead of interpolated value.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Updated test to expect URL-encoded app ID and /app path suffix. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Updated test to expect {country} and {configLink} placeholders instead of interpolated values.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5935 +/- ##
=======================================
Coverage 40.06% 40.06%
=======================================
Files 2473 2473
Lines 40170 40170
Branches 8821 8821
=======================================
+ Hits 16093 16095 +2
+ Misses 24050 24048 -2
Partials 27 27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 90 out of 91 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Summary
Introduces a centralized Jest mock for
react-intlthat automatically returnsdefaultMessagefor all internationalization functions, eliminating the need for repetitive intl setup across test files.Changes
__mocks__/react-intl.ts: Global mock that auto-returnsdefaultMessageforformatMessage,useIntl, andFormattedMessagecomponentsjest.config.js: Configured to use the centralized mockBenefits
{name}) instead of interpolated values, making assertions clearer - this is a pitfall in some casesExample
Before:
After:
// No setup needed - mock is applied globally🤖 Generated with Claude Code