Trying to write a Jest unit test for a file upload input element. Based on what i've found online, I'm trying to mock selecting a file by programmatically setting the files attribute on the input element like so: function selectFile(inputElement: HTMLInputElement) { const dataTransfer = new DataTransfer(); const mockFile = new File(['Hello World'], 'test-file.txt'); dataTransfer.items.add(mockFile); inputElement.files = dataTransfer.files; inputElement.dispatchEvent(new InputEvent('change')); return fixture.whenStable(); } However I just receive the error that "DataTransfer is not defined". Is there something I'm missing here? Why is DataTransfer undefined? Or how else am I supposed to mock selecting a file for a unit test with Jest? This is the post I found for reference. Here is another post of someone else using Jest and having the same issue. But the incident was closed without any resolution. Continue reading...