test: unify i18next mocks into centralized helpers#92
Conversation
Consolidate scattered i18next mock implementations across test files into a single source of truth. This reduces duplication and ensures consistent mock behavior. - Create test/i18n-mock.ts with reusable factory functions - Update vitest.setup.ts to use the centralized helpers - Remove redundant mock definitions from 8 test files - Update testing.md documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…eateReactI18nextMock` and detail global mock provisions.
Greptile Summary
Important Files Changed
Confidence score: 5/5
Sequence DiagramsequenceDiagram
participant Developer
participant TestFile
participant I18nMockHelper
participant ViTest
participant GlobalSetup
Developer->>TestFile: "Write/update test file"
TestFile->>I18nMockHelper: "Import createReactI18nextMock"
TestFile->>I18nMockHelper: "Call createReactI18nextMock({ 'key': 'value' })"
I18nMockHelper->>TestFile: "Return mock config"
TestFile->>ViTest: "vi.mock('react-i18next', mockConfig)"
ViTest->>GlobalSetup: "Load vitest.setup.ts"
GlobalSetup->>ViTest: "Apply global i18n mock"
ViTest->>TestFile: "Override with custom translations"
TestFile->>TestFile: "Render component"
TestFile->>TestFile: "Assert using custom translation"
|
There was a problem hiding this comment.
Additional Comments (1)
-
web/app/components/plugins/plugin-mutation-model/index.spec.tsx, line 18-27 (link)style: These i18n-config mocks may be inconsistent with the centralized i18next mocking approach. Consider moving these to the centralized helpers as well.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Context Used: Context from
dashboard- .cursorrules (source). Should these remaining i18n-config mocks also be moved to the centralized helpers for consistency?
21 files reviewed, 1 comment
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Benchmark PR from qodo-benchmark#437