Set default jest navigator language

Viewed 11

What's the best way to specify navigator language while running jest tests? I have a function calling toLocaleString, but it returns different values based on the language of the navigator.

I have tried

beforeEach(() => {
    jest.spyOn(global.navigator, 'language', 'get').mockReturnValue('en-US')
})

However, it gives me the error Cannot spyOn on a primitive value

0 Answers
Related