You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-10Lines changed: 9 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,7 +113,7 @@ await mongod.stop();
113
113
114
114
### Available options for MongoMemoryServer
115
115
116
-
All options are optional.
116
+
All options with `?`are optional, some options upon specified are required.
117
117
118
118
```js
119
119
constmongod=newMongoMemoryServer({
@@ -125,6 +125,7 @@ const mongod = new MongoMemoryServer({
125
125
storageEngine?: string, // by default `ephemeralForTest`(unless mongodb 7.0.0, where its `wiredTiger`), available engines: [ 'ephemeralForTest', 'wiredTiger' ]
126
126
replSet?: string, // by default no replica set, replica set name
127
127
args?: string[], // by default no additional arguments, any additional command line arguments for `mongod` `mongod` (ex. ['--notablescan'])
128
+
auth?: boolean, // add "--auth" argument, dont use this directly use top-level "auth"
128
129
},
129
130
binary?: {
130
131
version?: string, // by default '6.0.9'
@@ -136,18 +137,19 @@ const mongod = new MongoMemoryServer({
// enable needs to be set to "true", otherwise automatic user creation is by default disabled
141
+
enable?: boolean, // enable automatic user creation
140
142
customRootName?: string, // by default "mongodb-memory-server-root"
141
143
customRootPwd?: string, // by default "rootuser"
142
144
force?: boolean, // force creation of users
143
-
keyfileContent?: string, // by default "0123456789"
145
+
keyfileContent?: string, // by default "0123456789" (only useful for replsets)
144
146
extraUsers?: [{
145
147
// see mongodb documentation https://docs.mongodb.com/manual/reference/method/db.createUser/#definition)
146
148
createUser: string, // user name
147
149
pwd: string, // user password
148
150
roles: UserRoles[], // user roles
149
151
database?: string, // which database the user is created on
150
-
customData?: Record<string, any>,
152
+
customData?: Record<string, any>,// any arbitrary information, see mongodb documentation
151
153
mechanisms?: ('SCRAM-SHA-1'|'SCRAM-SHA-256')[],
152
154
authenticationRestrictions?: {
153
155
clientSource?: string;
@@ -189,21 +191,20 @@ const replSet = new MongoMemoryReplSet({
189
191
dbPath, // path to database files for this instance
190
192
storageEngine, // same storage engine options
191
193
},
192
-
// each entry will result in a MongoMemoryServer (replSet.count will not count towards here)
194
+
// each entry will result in a MongoMemoryServer (replSet.count will not limit the amount spawned by "instanceOpts")
193
195
],
194
196
// unless otherwise noted below these values will be in common with all instances spawned:
195
197
replSet: {
196
198
name, // replica set name (default: 'testset')
197
199
auth?: boolean | AutomaticAuth, // enable auth, for options see #available-options-for-mongomemoryserver
198
200
args, // any args specified here will be combined with any per instance args from `instanceOpts`
199
201
count, // number of additional `mongod` processes to start (will not start any extra if instanceOpts.length > replSet.count); (default: 1)
200
-
dbName, // default database for db URI strings. (default: uuid.v4())
202
+
dbName, // default database for db URI strings
201
203
ip, // by default '127.0.0.1', for binding to all IP addresses set it to `::,0.0.0.0`
202
-
oplogSize, // size (in MB) for the oplog; (default: 1)
203
204
spawn, // spawn options when creating the child processes
204
205
storageEngine, // default storage engine for instance. (Can be overridden per instance)
205
206
configSettings: {
206
-
// Optional settings for replSetInitiate command. See https://docs.mongodb.com/manual/reference/command/replSetInitiate/
207
+
// Optional settings for 'replSetInitiate' command. See https://docs.mongodb.com/manual/reference/command/replSetInitiate/
207
208
chainingAllowed: boolean, // When true it allows secondary members to replicate from other secondary members. When false, secondaries can replicate only from the primary.
208
209
heartbeatTimeoutSecs: number, // Number of seconds that the replica set members wait for a successful heartbeat from each other. If a member does not respond in time, other members mark the delinquent member as inaccessible.
209
210
heartbeatIntervalMillis: number, // The frequency in milliseconds of the heartbeats.
For additional information it is recommended to read this article [Testing a GraphQL Server using Jest with Mongoose](https://medium.com/entria/testing-a-graphql-server-using-jest-4e00d0e4980e)
248
-
249
248
### Test Runner Examples
250
249
251
250
[Documentation for Test Runner Integration Examples](https://nodkz.github.io/mongodb-memory-server/docs/guides/integration-examples/test-runners)
0 commit comments