I would like to mock the resolved value of navigator.userAgentData.getHighEntropyValues
in my test to be a sample object.
How can I do this?
I tried:
beforeEach(() => {
jest.mock(global.navigator.userAgentData);
});
it('uaFullVersion is defined', async () => {
global.navigator.userAgentData.getHighEntropyValues.mockResolvedValueOnce({uaFullVersion: '1.2.3'});
const hev = await myFunc();
expect(hev.uaFullVersion).toBeDefined();
});
myFunc:
async function myFunc() {
const hev = await navigator.userAgentData.getHighEntropyValues(["uaFullVersion"]);
return hev;
}
but I get the error
TypeError: Cannot read properties of undefined (reading 'getHighEntropyValues')