A Jest mock for expo-sqlite that allows testing SQLite-dependent code without a device or emulator. Current stable version is 4.0.0, compatible with expo-sqlite (expo-sqlite >=55) and expo >=55. It replaces expo-sqlite's native calls with better-sqlite3, enabling real SQLite database operations in test environments. Supports custom database file paths via the EXPO_SQLITE_MOCK environment variable for concurrent test isolation. Differentiates from simple mocks by executing actual SQL, catching constraint errors, and integrating with ORMs like drizzle. Release cadence is tied to expo-sqlite major versions, with breaking changes on major version bumps.
npm install expo-sqlite-mockNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows installation, jest configuration, and a basic test using expo-sqlite API with custom database per test worker.
Downgrade to expo-sqlite-mock@3 if using expo 53-54; or upgrade expo to >=55.
If on expo 51-52, use v2.x instead.
Use v1.x for expo-sqlite ~51.
Use console.JEST_WORKER_ID in the database path to isolate per-worker databases (e.g., ${__dirname}/test_${process.env.JEST_WORKER_ID}.db).For critical native-specific tests, supplement with integration tests on actual devices.
npm install -D expo-sqlite-mock and ensure setupFilesAfterEnv includes 'expo-sqlite-mock/src/setup.ts'.
Add 'expo-sqlite-mock/src/setup.ts' to setupFilesAfterEnv and restart Jest.
Ensure CREATE TABLE is called before any queries, e.g., using db.execAsync in beforeAll.
Use a fresh database per test or delete the file: delete process.env.EXPO_SQLITE_MOCK or set a unique path with process.env.JEST_WORKER_ID.