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.
Got the solution
Object.defineProperty(window.navigator, 'userAgent', {value : " "});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With