Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6288

Mocked Async storage test with jest fails, received null

$
0
0

Hello all I am new in testing, I am just trying to test async storage value, it's set to 25 as you see;

async value

This is test I have written;

test('can read asyncstorage', async () => {  let val = await AsyncStorage.getItem('isFirst');  expect(val).toBe('25');});

The error I am getting is that;

expect(received).toBe(expected) // Object.is equality    Expected: "25"    Received: null

Or did I just misunderstood the concept of writing tests? should I set 25 with mocked setItem just before calling getItem? Thank you.

Versions I use

"typescript": "^3.9.10""@types/react-native": "^0.64.10","@types/react-test-renderer": "^16.9.5",

Viewing all articles
Browse latest Browse all 6288

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>