How to mock navigation.useragent

Viewed 2626

I am tesing a react project using jest and react-testing-library.

The project has different code for navigator.useragent contains android / mobile / blackberry .

To test the code, I have to mock the navigation.useragent.

How I can achieve the mocking.

1 Answers

Got the solution

Object.defineProperty(window.navigator, 'userAgent', {value : " "});

Related