prisma-mock 1.0.0-alpha.9 → 1.0.0

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 +36 -38
  2. package/package.json +1 -1
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
 
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.0",
4
4
  "description": "Mock prisma for unit testing database",
5
5
  "main": "lib/index.js",
6
6
  "repository": {