Answer the question
In order to leave comments, you need to log in
Why doesn't TestUtils.Simulate.change work in react tests?
Hello. The previous question is related to the same, but he did not dare.
Component:
import React, { Component } from 'react';
export default class Test extends Component {
constructor(...props) {
super(...props);
}
render() {
return (
<div><input ref="input" /></div>
)
}
}
describe("Broker Full Page", function() {
let page;
beforeEach(function() {
page = TestUtils.renderIntoDocument(<BrokerFull />);
});
it("Change all inputs in BrokerFull page", function() {
let input = TestUtils.findRenderedDOMComponentWithTag(page, "input");
expect(input.getDOMNode().value).to.be.equal(''); // PASSED
TestUtils.Simulate.change(input, { target: { value: 'a' } });
expect(input.getDOMNode().value).to.be.equal('a'); // FILED
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question