Skip to content

mongodb-memory-server future-proofing #1230

@sspenst

Description

@sspenst

In mongodb-memory-server v10 the default mongodb binary was updated to v7 and mongodb has removed support for the ephemeralForTest engine

typegoose/mongodb-memory-server#889 (comment)
https://typegoose.github.io/mongodb-memory-server/docs/guides/migration/migrate10/#default-binary-version-is-now-7x
https://typegoose.github.io/mongodb-memory-server/docs/guides/mongodb-server-versions/#mongodb-memory-server-core-version-table

For now we can just use old mongodb binaries for tests, but eventually we may need to upgrade

The options seem to be

  1. Use wiredTiger engine on a RAM disk to run tests
mount -t tmpfs -o size=1G tmpfs /mnt/tmpfs
export MONGOMS_DBPATH=/mnt/tmpfs
  1. Run a persistent MongoDB instance locally and test against it (add a script to start/stop it automatically)
mongod --dbpath ./testdata --port 27017
beforeAll(async () => {
  await mongoose.connect('mongodb://localhost:27017/testdb', {
    useNewUrlParser: true,
    useUnifiedTopology: true,
  });
});

afterEach(async () => {
  // Cleanup after each test to ensure isolation
  await mongoose.connection.db.dropDatabase();
});

afterAll(async () => {
  await mongoose.connection.close();
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions