Skip to content

[Due for payment 2026-06-22] Add Jest test coverage for SQLiteProvider in react-native-onyx #91861

Closed

Description

@melvin-bot

Proposal made by Hubert here


Background

SQLiteProvider is the storage adapter Onyx uses on iOS and Android, built on top of react-native-nitro-sqlite. It owns every read, write, and merge that hits the on-device database — including hand-written SQL, JSON_PATCH/JSON_REPLACE merge logic, parameter binding, and the IN-list batch paths used during sync.

Onyx's existing test suite runs entirely in Node via Jest. Because react-native-nitro-sqlite is a native module with no Node implementation, the suite globally stubs it out in jestSetup.js, so the provider's SQL and merge code never actually executes against a database in CI. Today, the only way to exercise this code is to run the App on a real device or simulator.

Problem

When a developer changes a query, parameter binding, or merge path in SQLiteProvider, it may introduce SQL-shaped bugs (broken JSON_PATCH semantics, mis-bound :value placeholders, escaping mistakes, batch transaction errors). The only way to catch this today is via manual testing — which is slow, inconsistent, and easy to skip. Bugs may ship unnoticed and surface on users' devices.

Proposed Solution

Add a Jest mock of react-native-nitro-sqlite backed by an in-memory better-sqlite3 database, plus a new SQLiteProviderTest.ts that drives the real provider end-to-end against it.

  • The mock implements the slice of the Nitro surface the provider uses and maps Nitro's positional params onto better-sqlite3's named bindings so existing SQL runs unmodified.
  • The suite covers: setItem/getItem, multiSet/multiGet, multiMerge (both JSON_PATCH shallow/deep and JSON_REPLACE via replaceNullPatches), removeItem/removeItems, getDatabaseSize, clear, and SQL-injection safety on record_key.
  • Everything runs on the same CI that already runs the rest of the suite, on every PR — so the next SQL change is caught in seconds instead of in production.
  • No new patterns introduced: this follows the same approach already used in IDBKeyValProviderTest.

Draft PR

Expensify/react-native-onyx#794

Issue OwnerCurrent Issue Owner: @sosek108

Activity

  1. sosek108 commented on May 28, 2026

    @sosek108
    Contributor
  2. self-assigned this
    on May 29, 2026
  3. sosek108 commented on Jun 1, 2026

    @sosek108
    Contributor

    Bump PR in E/App: #92085

  4. melvin-bot commented on Jun 4, 2026

    @melvin-bot
    Author

    @sosek108 Whoops! This issue is 2 days overdue. Let's get this updated quick!

  5. sosek108 commented on Jun 8, 2026

    @sosek108
    Contributor

    Not overdue. Bump in in Onyx update queue

  6. changed the title [-]Add Jest test coverage for SQLiteProvider in react-native-onyx[/-] [+][Due for payment 2026-06-22] Add Jest test coverage for SQLiteProvider in react-native-onyx[/+] on Jun 15, 2026
  7. melvin-bot commented on Jun 15, 2026

    @melvin-bot
    Author

    Reviewing label has been removed, please complete the "BugZero Checklist".

  8. melvin-bot commented on Jun 15, 2026

    @melvin-bot
    Author

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.4.7-4 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-06-22. 🎊

    For reference, here are some details about the assignees on this issue:

    • @sosek108 does not require payment (Contractor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions