Closed
Description
react-testing-library
version:5.0.0react
version: 16.3.1, ^16.4.2node
version: 8.11.4npm
(oryarn
) version: yarn 1.9.4
Relevant code or config:
// TEST
import { render, fireEvent } from 'react-testing-library';
import App from './App';
it('Testing library fireEvent fires event', () => {
const handleChange = jest.fn();
const {getByTestId} = render(<App handleChange={handleChange}/>);
const input = getByTestId('test-input');
input.value = 'TEST VALUE';
fireEvent.change(input);
expect(handleChange).toHaveBeenCalledTimes(1);
});
//COMPONENT
class App extends Component {
constructor(props) {
super(props);
this.state = {
value: ''
};
this.handleChange = this.handleChange.bind(this);
}
handleChange = (e) => {
console.log('calling handle change');
const { value } = e.target;
this.setState({ value });
this.props.handleChange(e);
};
render() {
return (
<div className="App">
<input value={this.state.value} onChange={this.handleChange} data-testid="test-input" />
</div>
);
}
}
export default App;
Reproduction:
https://github.com/snaumov/repro-for-kent
Problem description:
The above test fails on react-testing-library 5.0.0 (handleChange not fired), but works in 4.1.8.
Suggested solution:
Will keep looking into that, appreciate any direction.
Metadata
Metadata
Assignees
Labels
No labels