test: unify i18next mocks into centralized helpers#7
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.
🤖 Augment PR SummarySummary: This PR centralizes and standardizes frontend i18n mocking for Vitest by introducing a shared Changes:
Technical Notes: Custom translation strings for assertions can now be supplied via 🤖 Was this summary useful? React with 👍 or 👎 |
| */ | ||
| export function createUseTranslationMock(translations: TranslationMap = {}) { | ||
| return { | ||
| useTranslation: () => ({ |
There was a problem hiding this comment.
createUseTranslationMock’s useTranslation mock ignores the namespace argument (e.g. useTranslation('datasetSettings')), so t('key') won’t get the default namespace prefix unless callers pass options.ns. This diverges from real react-i18next usage patterns and the previous global mock behavior, so some tests may silently assert on the wrong strings.
🤖 Was this useful? React with 👍 or 👎
| */ | ||
| export function createTransMock(translations: TranslationMap = {}) { | ||
| return { | ||
| Trans: ({ i18nKey, children }: { |
There was a problem hiding this comment.
|
|
||
| /** | ||
| * Create a t function with optional custom translations | ||
| * Checks translations[key] first, then translations[ns.key], then returns ns.key as fallback |
There was a problem hiding this comment.
Benchmark PR from agentic-review-benchmarks#7