title: Jest Enzyme Test for A Component
body: <p>I have a loader component </p>
  
  <pre><code>import React from 'react'
  import { withStyles } from '@material-ui/styles';
  import logo from '../../assets/images/hydra_eco_logo.png'
  
  const styles = theme =&gt; ({
      image: {
          position: "absolute",
          top: "50%",
          left: "50%",
          width: "120px",
          height: "120px",
          margin: `-60px 0 0 -60px`,
          animation:`spin 4s linear infinite`,
          borderRadius: `30%`
      },
      "@keyframes spin" : { 
          "100%" : { 
              transform: "rotate(360deg)" 
          } 
      }
  });
  
  
  
  const Loader = (props) =&gt; {
      const classes = props.classes
      return(
          &lt;div className={classes.loader}&gt;
              &lt;img className={classes.image} src={logo} alt="Loader Image"  /&gt;
          &lt;/div&gt;
      )
  }
  
  
  export default withStyles(styles)(Loader);
  </code></pre>
  
  <p>so I want to test if the Loader is rendered or not and the loader image is loaded or not
  my test file looks like this </p>
  
  <pre><code>import React from 'react';
  import '../../../setupTests'
  import { shallow} from 'enzyme';
  import Loader from './Loader';
  import renderer from 'react-test-renderer';
  import logo from '../../assets/images/hydra_eco_logo.png';
  
  
  describe('&lt;Loader /&gt;', () =&gt; {
      it('should render without throwing an error', function() {
          expect(shallow(&lt;Loader /&gt;).find('div img').prop("src")).toEqual(logo);
      });
  
      it('match src of loader image', function() {
          const wrapper = shallow(&lt;Loader /&gt;);
          const image = wrapper.find('div img')
          expect(image).toBeTruthy();
          expect(image.prop("src")).toEqual(logo); 
      });
  })
  </code></pre>
  
  <p>It throws error <code>Method “props” is meant to be run on 1 node. 0 found instead.</code>
  I tried resolving it, it comes out it cannot be used for nested elements such as I have img under div, since I am new to testing and React I need help ! Thank you</p>