Async-storage: mocking v2 async storage in jest

Created on 15 Jan 2020  路  4Comments  路  Source: react-native-async-storage/async-storage

You want to:

Trying to write some tests around my code with the v2 version but having a bit of trouble mocking out the native module. Some direction here would be great as i think it is a bit different to how legacy is mocked.

v2

Most helpful comment

@Krizzu I wrote a basic mock implementation which so far seems to be working just fine 馃檪 I'd really appreciate it if you could take a quick look to be sure there's nothing missing. Thanks a lot!!

All 4 comments

@codecog

You'd have to mock whole @react-native-community/async-storage-backend-legacy module or React-Native's NativeModules module. Here's a mock for current version to get an idea for mock implementation.

I'll put mock to roadmap for v2.

Great! Thanks @Krizzu

@Krizzu I wrote a basic mock implementation which so far seems to be working just fine 馃檪 I'd really appreciate it if you could take a quick look to be sure there's nothing missing. Thanks a lot!!

@JoseLion
This looks legit. Unfortunately, I'm putting v2 on hold from my side, but feel free to open PR.

Related ticket: #279

Was this page helpful?
0 / 5 - 0 ratings