Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion docs/content/docs/guides/node-test-mock.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@ Import `react-native-nitro-sqlite/mock` to test SQLite connections in Node witho

## Set up Jest

Add a setup file to your existing Jest `setupFilesAfterEnv` configuration:
The package ships ES modules. Jest runs tests as CommonJS and skips transforming files in `node_modules` by default, so add `react-native-nitro-sqlite` to the packages your `transformIgnorePatterns` lets Jest transform. If your pattern already lists other packages, add it to that list:

```js
// jest.config.js
module.exports = {
// ...your existing configuration
transformIgnorePatterns: [
'node_modules/(?!((jest-)?react-native|@react-native(-community)?|react-native-nitro-sqlite)/)',
],
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
}
```

Then reset the mock databases in that setup file:

```ts
// jest.setup.ts
Expand Down
41 changes: 8 additions & 33 deletions packages/react-native-nitro-sqlite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,23 @@
"description": "Fast SQLite library for React Native built using Nitro Modules",
"main": "./lib/module/index",
"module": "./lib/module/index",
"types": "./lib/typescript/module/index.d.ts",
"types": "./lib/typescript/index.d.ts",
"source": "./src/index",
"react-native": "./src/index",
"exports": {
".": {
"react-native": "./src/index.ts",
"import": {
"types": "./lib/typescript/module/index.d.ts",
"default": "./lib/module/index.js"
},
"require": {
"types": "./lib/typescript/commonjs/index.d.ts",
"default": "./lib/commonjs/index.js"
}
"types": "./lib/typescript/index.d.ts",
"default": "./lib/module/index.js"
},
"./errors": {
"react-native": "./src/errors.ts",
"import": {
"types": "./lib/typescript/module/errors.d.ts",
"default": "./lib/module/errors.js"
},
"require": {
"types": "./lib/typescript/commonjs/errors.d.ts",
"default": "./lib/commonjs/errors.js"
}
"types": "./lib/typescript/errors.d.ts",
"default": "./lib/module/errors.js"
},
"./mock": {
"import": {
"types": "./lib/typescript/module/mock.d.ts",
"default": "./lib/module/mock.js"
},
"require": {
"types": "./lib/typescript/commonjs/mock.d.ts",
"default": "./lib/commonjs/mock.js"
}
"types": "./lib/typescript/mock.d.ts",
"default": "./lib/module/mock.js"
}
},
"files": [
Expand Down Expand Up @@ -148,12 +130,6 @@
"source": "src",
"output": "lib",
"targets": [
[
"commonjs",
{
"esm": true
}
],
[
"module",
{
Expand All @@ -164,8 +140,7 @@
"typescript",
{
"tsc": "../../node_modules/.bin/tsc",
"project": "tsconfig.build.json",
"esm": true
"project": "tsconfig.build.json"
}
]
]
Expand Down
Loading