title: Jest+React Native Testing Library: How to test an image src?
body: <p>In my new React Native app, I want to add some Jest tests.</p>
  <p>One component renders a background image, which is located directly in the project in <code>assets</code> folder.</p>
  <p>Now I stumbled about how to test if this image is actually taken from this path, therefore present in the component, and rendered correctly.</p>
  <p>I tried using <code>toHaveStyle</code> from <code>@testing-library/jest-native</code> with a container, which returned the error <code>toHaveStyle</code>is not a function. Then I tried the same with <code>queryByTestId</code>, same error. When I do     <code>expect(getByTestId('background').toBeInTheDocument);</code> then I feel this is useless, because it only checks if an element with this testId is present, but not the image source.</p>
  <p>Please, how can I test this? Does it actually make sense to test an image source after all?</p>
  <p>Here is my code:</p>
  <p>1.) The component that should be tested (<code>Background</code>):</p>
  <pre class="lang-js prettyprint-override"><code>const Background: React.FC&lt;Props&gt; = () =&gt; {
    const image = require('../../../../assets/images/image.jpg');
      
    return (
      &lt;View&gt;
        &lt;ImageBackground testID=&quot;background&quot; source={image} style={styles.image}&gt;&lt;/ImageBackground&gt;
      &lt;/View&gt;
    );
  };
  </code></pre>
  <p>2.) The test:</p>
  <pre class="lang-js prettyprint-override"><code>import React from 'react';
  import {render, container} from 'react-native-testing-library';
  import {toHaveStyle} from '@testing-library/jest-native';
  import '@testing-library/jest-native/extend-expect';
  import Background from '../Background';
  
  describe('Background', () =&gt; {   
    test('renders Background image', () =&gt; {
      const {getByTestId} = render(&lt;Background&gt;&lt;/Background&gt;);
      expect(getByTestId('background').toBeInTheDocument);
  
  /*    const container = render(&lt;Background background={background}&gt;&lt;/Background&gt;);
  expect(container).toHaveStyle(
    `background-image: url('../../../../assets/images/image.jpg')`,
  ); */
  
  /*     expect(getByTestId('background')).toHaveStyle(
    `background-image: url('../../../../assets/images/image.jpg')`,
  ); */
  
    });
  });
  </code></pre>