expo-sqlite-mock
v3.0.2
Published
[](https://github.com/zfben/expo-sqlite-mock/blob/main/packages/faasjs/jest/LICENSE) [](https://www.npmjs.com/package/expo-s
Downloads
9,142
Readme
expo-sqlite-mock
Use expo-sqlite with jest.
Notice
- ^3.0.0 is for expo-sqlite >=53.
- ^2.0.0 is for expo-sqlite ~52.
- ^1.0.0 is for expo-sqlite ~51.
Usage
npm install -D expo-sqlite-mockorbun add -D expo-sqlite-mock- Add
"setupFilesAfterEnv": ["expo-sqlite-mock/src/setup.ts"]and"testTimeout": 10000to your jest config (It's inpackage.jsonfor default expo project).
Example:
{
"jest": {
"preset": "jest-expo",
"setupFilesAfterEnv": ["expo-sqlite-mock/src/setup.ts"],
"testTimeout": 10000
}
}Advanced
You can set the EXPO_SQLITE_MOCK environment variable to a custom SQLite database location.
Tips:
- Please use
JEST_WORKER_IDto avoid concurrent test cases writing to the same file. - Update your
.gitignoreto ignore the SQLite database file.
Example:
it("test", async () => {
// or you can set it beforeAll or beforeEach
process.env.EXPO_SQLITE_MOCK = `${__dirname}/test_${process.env.JEST_WORKER_ID}.db`;
// your test code
// clear the env var
delete process.env.EXPO_SQLITE_MOCK;
});Changelog
3.0.2
- Constraint error handling.
3.0.0
- Compatible with expo-sqlite ~15 and expo ~53.
2.2.0
- Compatible with drizzle
- Clean up the code
2.1.0
- Support custom SQLite database location by setting the
EXPO_SQLITE_MOCKenvironment variable. - Update peer dependencies.
- Support custom SQLite database location by setting the
2.0.1
- Fix setup.
2.0.0
- Update for expo-sqlite ~52.
1.0.0
- Initial version.
