prisma-mock 1.0.0-alpha.9 → 1.0.1-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +37 -42
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -76,34 +76,16 @@ beforeEach(() => {
76
76
  })
77
77
  ```
78
78
 
79
+ ## API
80
+
79
81
  ### Exports
80
82
 
81
83
  The library provides three different exports:
82
84
 
83
85
  - **`prisma-mock`** (default): The recommended way to use the library. Automatically uses the Prisma client from `@prisma/client/default`, so you don't need to pass Prisma as an argument.
84
- - **`prisma-mock/client`**: Use this when you need to explicitly pass the Prisma namespace (try the default export first).
86
+ - **`prisma-mock/client`**: Use this when you need to explicitly pass the Prisma namespace.
85
87
  - **`prisma-mock/legacy`**: The old API for backward compatibility. This export is deprecated but maintained for existing codebases.
86
88
 
87
- ### Legacy Export
88
-
89
- The legacy export maintains the old API signature for backward compatibility:
90
-
91
- ```js
92
- import createPrismaMock from "prisma-mock/legacy"
93
- import { mockDeep } from "jest-mock-extended"
94
-
95
- const client = createPrismaMock(
96
- { user: [{ id: 1, name: "John" }] }, // data
97
- Prisma.dmmf.datamodel, // datamodel (optional)
98
- mockDeep(), // mockClient (optional)
99
- { enableIndexes: true } // options (optional)
100
- )
101
- ```
102
-
103
- **Note**: If you're starting a new project, use the default export instead. The legacy export is only for maintaining existing codebases that haven't migrated yet.
104
-
105
- ## API
106
-
107
89
  ### Default Export (`prisma-mock`)
108
90
 
109
91
  ```ts
@@ -118,6 +100,24 @@ createPrismaMock<P extends PrismaClient = PrismaClient>(
118
100
  ): P & { $getInternalState: () => Required<PrismaMockData<P>> }
119
101
  ```
120
102
 
103
+ ### Parameters
104
+
105
+ - **`options`** (optional): Configuration options (see below)
106
+
107
+ #### Options
108
+
109
+ - **`data`** (optional): Initial mock data for the Prisma models. An object containing keys for tables and values as arrays of objects.
110
+ - **`datamodel`** (optional): The Prisma datamodel, typically `Prisma.dmmf.datamodel` (default).
111
+ - **`mockClient`** (optional): A `jest-mock-extended` or `vitest-mock-extended` instance. If not provided, a plain object is used instead.
112
+ - **`caseInsensitive`** (boolean, default: `false`): If true, all string comparisons are case insensitive
113
+ - **`enableIndexes`** (boolean, default: `true`) If true, enables indexing for better query performance on primary keys, unique fields, and foreign keys
114
+
115
+ ### Return Value
116
+
117
+ Returns a mock Prisma client with all standard model methods plus:
118
+
119
+ - `$getInternalState()`: Method to access the internal data state for testing/debugging
120
+
121
121
  ### Client Export (`prisma-mock/client`)
122
122
 
123
123
  ```ts
@@ -133,30 +133,28 @@ createPrismaMock<PClient extends PrismaClient, P extends typeof Prisma = typeof
133
133
  ): PClient & { $getInternalState: () => Required<PrismaMockData<PClient>> }
134
134
  ```
135
135
 
136
- ### Parameters
137
-
138
- #### Default Export
139
-
140
- - **`options`** (optional): Configuration options (see below)
141
-
142
- #### Client Export
136
+ #### Parameters
143
137
 
144
138
  - **`prisma`** (required): The Prisma namespace (e.g., `Prisma` from `@prisma/client`). This is used to access the datamodel and type information.
145
- - **`options`** (optional): Configuration options (see below)
139
+ - **`options`** (optional): Configuration options. Same as the default export, with the exception of the `datamodel` not being optional.
146
140
 
147
- #### Options
141
+ ### Legacy Export (`prisma-mock/legacy`)
148
142
 
149
- - **`data`** (optional): Initial mock data for the Prisma models. An object containing keys for tables and values as arrays of objects.
150
- - **`datamodel`** (optional): The Prisma datamodel, typically `Prisma.dmmf.datamodel`. Defaults to the Prisma client's datamodel.
151
- - **`mockClient`** (optional): A `jest-mock-extended` or `vitest-mock-extended` instance. If not provided, a plain object is used instead.
152
- - **`caseInsensitive`** (boolean, default: `false`): If true, all string comparisons are case insensitive
153
- - **`enableIndexes`** (boolean, default: `true`) If true, enables indexing for better query performance on primary keys, unique fields, and foreign keys
143
+ The legacy export maintains the old API signature for backward compatibility:
154
144
 
155
- ### Return Value
145
+ ```js
146
+ import createPrismaMock from "prisma-mock/legacy"
147
+ import { mockDeep } from "jest-mock-extended"
156
148
 
157
- Returns a mock Prisma client with all standard model methods plus:
149
+ const client = createPrismaMock(
150
+ { user: [{ id: 1, name: "John" }] }, // data
151
+ Prisma.dmmf.datamodel, // datamodel (optional)
152
+ mockDeep(), // mockClient (optional)
153
+ { enableIndexes: true } // options (optional)
154
+ )
155
+ ```
158
156
 
159
- - `$getInternalState()`: Method to access the internal data state for testing/debugging
157
+ **Note**: If you're starting a new project, use the default export instead. The legacy export is only for maintaining existing codebases that haven't migrated yet.
160
158
 
161
159
  ## DMMF Generator
162
160
 
@@ -216,6 +214,7 @@ const client = createPrismaMock(Prisma, {
216
214
  - `upsert`
217
215
  - `count`
218
216
  - `aggregate`
217
+ - `groupBy`
219
218
 
220
219
  ### Model Query Options ✅
221
220
 
@@ -307,8 +306,6 @@ The following features are planned but not yet implemented:
307
306
 
308
307
  ### Model Queries
309
308
 
310
- - `groupBy`
311
-
312
309
  ### Nested Queries
313
310
 
314
311
  - `connectOrCreate`
@@ -337,7 +334,6 @@ The following features are planned but not yet implemented:
337
334
  ### Attributes
338
335
 
339
336
  - `auto()`
340
- - `dbgenerated()`
341
337
 
342
338
  ### Referential Actions
343
339
 
@@ -348,7 +344,6 @@ The following features are planned but not yet implemented:
348
344
 
349
345
  ### Prisma Client Methods
350
346
 
351
- - `$transaction` (Isolation levels)
352
347
  - `$use` (Middleware)
353
348
 
354
349
  ## Performance Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-mock",
3
- "version": "1.0.0-alpha.9",
3
+ "version": "1.0.1-alpha.3",
4
4
  "description": "Mock prisma for unit testing database",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -55,7 +55,7 @@
55
55
  "changeset:validate:ci": "changeset status --since=origin/main --verbose"
56
56
  },
57
57
  "peerDependencies": {
58
- "@prisma/client": "^3.5.0 || ^4.7.0 || ^5.0.0 || ^6.0.0"
58
+ "@prisma/client": "^3.5.0 || ^4.7.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
59
59
  },
60
60
  "dependencies": {
61
61
  "@prisma/generator-helper": "^6.19.0",