vendredi 17 novembre 2017

How can I change the value of input in react test

I'd like to test a form of my react-app.

I have removed 'disabled' property of button when doing following things.

const component = TestUtils.renderIntoDocument(<Mycomponent/>);
const myDOM =findDOMNode(component);
const input = myDOM.querySelector('input');
input.value = "2017-11-11";
let submitButton = myDOM.querySelector('button');
TestUtils.Simulate.click(submitButton);
...
const newlyAddedDate = record.querySelector('#date').innerHTML;
console.log("newlyAddedDate:"+newlyAddedDate);

but the output in console is

"newlyAddedDate:" 

This react-app performs correctly in chrome. I believe it's the problem of

"input.value="2017-11-11";

This sentence failed to change the value in the inputbox.

So how can i set the value in a inputbox when doing react-test?

Here's the repo of this app http://ift.tt/2ASUQfU

Aucun commentaire:

Enregistrer un commentaire