'Render() Modal test Jest Enzyme
I am not really how to test render() Modal. I am able to set up the props and test Render () " make sure it render with all the props" correctly " without any problems. But when it comes to Render Modal - i might be missing something
Using ReactJS 15 - jest enzyme VSC
it(' Should render with all of the props ', () => {
tree = renderer.create(<Component {...baseProps} />)
let treeJson = tree.toJSON()
expect(treeJson).toMatchSnapshot();
tree.unmount()
});
I found this online but and try to test it but i believe there might be something missing. Any ideas?
it('renders correctly', () => {
const wrapper = mount( <Component modalOpen/> );
expect(wrapper).toMatchSnapshot();
// Passes
expect(wrapper.find('.outside')).toHaveLength(1);
// Construct new wrapper rooted at modal content
inside_els = document.getElementsByClassName("inside")[0]
inside_wrapper = new ReactWrapper(inside_els, true)
// Passes
expect(inside_wrapper.find('.inside')).toHaveLength(1);
Here is an example of render() Modal
render() {
//console.log(this.props)
return (
<Modal isOpen={this.props.isOpen} style={modalStyle}>
<div className='security-search-wrapper-modal'>
<div className='fullmodal'>
<div className='fullmodal_title'>Batch Update</div>
<div title="Close Window" className="add-custom-field-close"
onClick={() => {this.closeModal()}}><FontAwesome name='xbutton'
className='fa-times' /></div>
</div>
Solution 1:[1]
After some research : I was able to find this:
https://github.com/reactjs/react-modal/issues/563
Feel free to comment
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | userr2591 |