typegoose / mongodb-memory-server

Manage & spin up mongodb server binaries with zero(or slight) configuration for tests.
https://typegoose.github.io/mongodb-memory-server/
MIT License
2.58k stars 187 forks source link

No export of MongoMemoryServerOpts in package #795

Closed nicholasfoden closed 1 year ago

nicholasfoden commented 1 year ago

package:


What is your question?

Would it be possible to export MongoMemoryServerOpts and MongoMemoryReplSetOpts type in one of the packages?

Or is there a good reason why it is not exported?

Use case

Writing a factory which spins up and seeds a database with test data

Example proposed usage

function createTestDatabaseFactory(seed: SomeDataType, options: MongoMemoryServerOpts){
   const myinstance: MongoMemoryServer = MongoMemoryServer.create(options);
   // ... do some other things to seed the database
   return myinstance;
} 

Thanks for looking at this issue.

hasezoey commented 1 year ago

interface MongoMemoryServerOpts is exported, just not in the main entry-point, you will have to use direct import if you want to use it.

instead of import { MongoMemoryServerOpts } from "mongodb-memory-server-core" you have to import { MongoMemoryServerOpts } from "mongodb-memory-server-core/lib/MongoMemoryServer"

or you could alternatively also use Parameters<MongoMemoryServer['create']>[0] instead of MongoMemoryServerOpts directly