gotwarlost / istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k stars 786 forks source link

Testing code that depends on the browser clipboard? #832

Closed ajmas closed 7 years ago

ajmas commented 7 years ago

Does anyone have any suggestions on how to test code that depends on the browser's clipboard. In our case we want to test something that is handling the onPaste event:

function handleOnPaste(event) {
     event.preventDefault();
     const data = event.clipboardData.getData('Text');
     // other code here
}
ajmas commented 7 years ago

Closing because this can be solved via React TestUtils.