title: jest test fails after installing react-native-async-storage
body: <p>In my react native project, I have recently installed node module react-native-async-storage as I received warnings about the native package from 'react-native' being deprecated and moved out to an individual module. </p>
  
  <p>After installing the <code>@react-native-community/async-storage</code> my jest test is failing. </p>
  
  <p>first with following <code>error: unexpected token at position 0</code></p>
  
  <p>in file:</p>
  
  <p><strong>persistence.js</strong></p>
  
  <pre><code>import AsyncStorage from '@react-native-community/async-storage';
  
  storeData = async ({ key, value }) =&gt; {
    try {
      await AsyncStorage.setItem(key, value);
    } catch (error) {
      // Error saving data
    }
  }
  
  retrieveData = async (key) =&gt; {
    try {
      const value = await AsyncStorage.getItem(key);
      if (value !== null) {
        // Our data is fetched successfully
        return value;
      }
    } catch (error) {
      // Error retrieving data
    }
  }
  
  module.exports = {
    storeData,
    retrieveData
  }
  </code></pre>
  
  <p>So I assume this is related to some babel configuration, since i encountered something similar last time i installed a package from the @react-native-community</p>
  
  <p>So, to the <code>transformIgnorePatterns</code> in my package.json I added following:</p>
  
  <pre><code>  "jest": {
      "preset": "react-native",
      "transformIgnorePatterns": [
        "node_modules/(?!react-native|@react-native-community/async-storage|native-base-shoutem-theme|@shoutem/animation|@shoutem/ui|tcomb-form-native)"
      ]
    }
  </code></pre>
  
  <p>But now I'm getting a new error. <code>@RNCommunity/AsyncStorage: NativeModule.RCTAsyncStorage is null.</code></p>
  
  <p>I'm pasting the screenshot to show my project dir so that you can get an idea about which config files a have available to mess with.
  <a href="https://i.stack.imgur.com/YC43f.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YC43f.png" alt="enter image description here"></a></p>
  
  <p>As I can see most related topic are about mocking the asyncStorage function I've tried to do so, without any luck. I added following to my one and only tests file:</p>
  
  <pre><code>import MockAsyncStorage from 'mock-async-storage';
  
  beforeAll(() =&gt; { 
    const mockImpl = new MockAsyncStorage()
    jest.mock('AsyncStorage', () =&gt; mockImpl)
    snapshot = renderer.create(&lt;App /&gt;);
  })
  
  afterAll(() =&gt; {
    jest.unmock('AsyncStorage')
  });
  </code></pre>
  
  <p>Still no cigar. I have tried adding a <code>setupFilesAfterEnv.js</code> with configurations as other answer suggests, also didn't do the trick.</p>