Jest :: Mock navigator.Useragent is not working in browser as well as in test case

16 views Asked by At

Im trying to change the navigator userAgent through jest and for different agent we have different code to be executed.It seems not possible to override.Even in the browser im not able to overrride

Object.defineProperty(window.navigator, 'userAgent', { value: 'xxx', writable:true, configurable: true });
VM517:1 Uncaught TypeError: Cannot redefine property: userAgent
    at Function.defineProperty (<anonymous>)
    at <anonymous>:1:8
0

There are 0 answers