Wednesday, 8 June 2022

mock ontouchstart event in window object jest

I'm trying to mock ontouchstart event in window object to make some tests, but i can't find a proper way to do it

export const main = () =>
  !!('ontouchstart' in window || navigator.maxTouchPoints);

I try to do

 it('123', () => {
    const spyWindowOpen = jest.spyOn(window, 'ontouchstart');
    spyWindowOpen.mockImplementation(jest.fn());
  });

but ontouchstart does not seem exist on window object in my compilation tests



from mock ontouchstart event in window object jest

No comments:

Post a Comment