title: How to test Async Storage with Jest?
body: <p>I'm building an app with React Native. I want to minimize how often I communicate to the database, so I make heavy use of AsyncStorage. There's a lot of room for bugs in the translation between DB and AsyncStorage though. Therefore, I want to make sure that AsyncStorage has the data I believe it does by running automated tests against it. Surprisingly, I haven't found any information on how to do that online. My attempts to do it on my own haven't worked out. </p>
  
  <p>Using Jest: </p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>it("can read asyncstorage", () =&gt; {
  return AsyncStorage.getItem('foo').then(foo =&gt; {
    expect(foo).not.toBe("");
  });  });
  </code></pre>
  
  <p>This method failed with an error: </p>
  
  <pre class="lang-js prettyprint-override"><code>TypeError: RCTAsyncStorage.multiGet is not a function
  </code></pre>
  
  <p>Removing the return will cause it to run instantly without waiting for the value and improperly pass the test. </p>
  
  <p>I got hit with the exact same error when I tried to test it using the await keyword:</p>
  
  <pre class="lang-js prettyprint-override"><code>it('can read asyncstorage', async () =&gt; {
  this.foo = "";
  await AsyncStorage.getItem('foo').then(foo =&gt; {
      this.foo = foo;
  });
  expect(foo).not.toBe(""); });
  </code></pre>
  
  <p>Any suggestions on how to successfully run assertions against the values in AsyncStorage? I'd prefer to continue using Jest but if it can only be done with some alternate testing library I'm open to that. </p>