Unable to have a real time key event in text area for unit cases in react

keyDown simulation should only take keyCode value. Try it like this:

component.find('.text-area').simulate('keyDown', { keyCode: 'k'});

And the jsx should be like this:

    onChange={(e) => {
        this.setState({ textArea: e.target.value });
    onKeyDown={(e) => {
        this.setState({ textArea: e.keyCode });

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top