Expensify / react-native-onyx

Persistent, offline-first state management solution for React Native. Easy to use with minimal config and boilerplate.
MIT License
153 stars 71 forks source link

Create mock implementations for `react-native-quick-sqlite` and `idb-keyval` #529

Open chrispader opened 5 months ago

chrispader commented 5 months ago

As described in this P/S proposal i want to create mock implementations directly in react-native-quick-sqlite and idb-keyval, which we can then use to improve and add new (unit) tests in Onyx.

Proposal

Create a mock for react-native-quick-sqlite (and idb-keyval) to allow for testing the actual storage providers on different platforms :test_tube:

Problem

From time to time we experience (sometimes critical) bugs and problems with edge-cases in Onyx and therefore also in E/App. These are often caused by the underlying storage library on (only) one platform, native or web. In Onyx we are only testing the actual library logic, but storage implementation of the underlying storage providers - like SQLite and IndexedDB - remains untested.

Solution

Implement a mock for react-native-quick-sqlite (and idb-keyval) and use it within Onyx for unit and E2E tests. The storage providers we use in Onyx are working very differently but we're trying to use the same similarly for the most part. In order for the library to work the same on all platform, we should test the actual storage provider implementations on all platforms. We can then potentially also improve more exhaustive tests for flows and use-cases in E/App

@tgolen @roryabraham just checking if i can already start working on this, since the proposal got 4 upvotes (2 from Expensify employees) and no downvotes or negative comments.

tgolen commented 5 months ago

I think it's fine to start working on this, yeah.