Material UI + Enzyme testing component

前端 未结 3 1039
一生所求
一生所求 2021-02-04 11:25

I have component in React which I\'m trying to test with Jest, unfortunately test do not pass.

The component code:

import React, {Component} from \'react         


        
3条回答
  •  孤城傲影
    2021-02-04 12:18

    Something like this worked for me:

    import {createMount} from '@material-ui/core/test-utils';
    
    const WrappedComponent = () => 
        
            
        
    
    const render = createMount();
    const wrapper = render();
    
    const state = wrapper.find(MyComponent).instance().wrappedInstance.state
    

提交回复
热议问题