You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jason Godesky edited this page Jul 17, 2026
·
3 revisions
mockLocalize mocks Foundry’s game.i18n.localize utility method so that you can test code that uses it.
Parameters
translations?: Record<string, string>
The dictionary of localizations that you would like the mock to use. Any key not in the dictionary returns itself. If you don’t provide a dictionary, then no key can be found in it, so every key returns itself.
Examples
import{beforeEach,afterEach,describe,expect,it,vi}from'vitest'import{mockLocalize}from'@revolutionarygamesco/common-foundryvtt/mocks'describe('Localization',()=>{beforeEach(()=>{mockLocalize({'TestModule.examples.mockLocalize': 'This is just an example'})})afterEach(()=>{vi.unstubAllGlobals()})it('localizes the string',()=>{expect(game.i18n.localize('TestModule.examples.mockLocalize')).toBe('This is just an example')})})