Skip to content

test: unify i18next mocks into centralized helpers#7

Open
tomerqodo wants to merge 5 commits into
cursor_full_base_test_unify_i18next_mocks_into_centralized_helpers_pr7from
cursor_full_head_test_unify_i18next_mocks_into_centralized_helpers_pr7
Open

test: unify i18next mocks into centralized helpers#7
tomerqodo wants to merge 5 commits into
cursor_full_base_test_unify_i18next_mocks_into_centralized_helpers_pr7from
cursor_full_head_test_unify_i18next_mocks_into_centralized_helpers_pr7

Conversation

@tomerqodo

@tomerqodo tomerqodo commented Jan 25, 2026

Copy link
Copy Markdown

Benchmark PR from agentic-review-benchmarks#7


Note

Unifies frontend i18n mocking across tests and clarifies mocking guidance.

  • Adds web/test/i18n-mock.ts with createReactI18nextMock, createUseTranslationMock, createTransMock, and createTFunction
  • Updates global mock in web/vitest.setup.ts to use the shared helper
  • Refactors numerous *.spec.tsx files to remove ad-hoc react-i18next mocks, use the helper, and adjust expectations for namespace-prefixed keys
  • Enhances testing docs/templates (.claude/.../mocking.md, web/testing/testing.md, component test template) to document the global i18n mock and override pattern

Written by Cursor Bugbot for commit 3c622b1. Configure here.

hyoban and others added 5 commits January 25, 2026 12:05
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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment thread web/test/i18n-mock.ts
changeLanguage: vi.fn(),
},
}),
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useTranslation mock ignores defaultNs parameter

Low Severity

The createUseTranslationMock function creates a useTranslation mock that doesn't accept any parameters (line 41), but createTFunction was designed to receive a defaultNs parameter (line 10). This means the defaultNs parameter in createTFunction can never receive a value through useTranslation('namespace'). While this doesn't break current tests (the codebase uses inline { ns: 'namespace' } options instead), it's inconsistent with the documented i18next pattern and creates dead code.

Fix in Cursor Fix in Web

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.

3 participants