I want to test that the console.log function is being called when the user presses the Enter key by an interactive HTMLElement. I've been trying to mock an event object of the function bellow in Jest with Typescript but it is not working. How to mock event object in React/Typescript with Jest?
Example:
import React from 'react';
function handleKey(event: React.KeyboardEvent) {
if (event.key === 'Enter') {
console.log('The enter key has been clicked');
}
}