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

Problem with local jest Unit test with Change Stream #793

Closed fangdanzai closed 1 year ago

fangdanzai commented 1 year ago

Versions

package: mongo-memory-server : mongo-memory-server

What is your question?

I tried to use mongodb-memory-server to create a local unit test, and here's my setup:

this.mongoServer = await MongoMemoryReplSet.create({
      replSet: {
        dbName: this.database,
        storageEngine: "wiredTiger",
      },
      binary: {
        version: "5.0.13",
        downloadDir: "etc/mongo_binaries",
      },
    });

I also created a changeStreamClient to connect to the database I built. Once the program start to watch the data-set, I tried to delete one Document in the watched collection but changeStream.on() is not triggered in unit test.

Any one knows the reason?

hasezoey commented 1 year ago

please provide a full reproduction example, as it likely is related to how it is used

PS: next time please use proper code-formatting (ie no spaces for a code-block and add the language)

noghartt commented 1 year ago

You can't test changeStream with wiredTiger storage engine

hasezoey commented 1 year ago

You can't test changeStream with wiredTiger storage engine

did you mean to say ephermeralForTest? because official mongodb docs say this about Availability for Change Streams:

The replica sets and sharded clusters must use the WiredTiger storage engine. Change streams can also be used on deployments that employ MongoDB's encryption-at-rest feature.

source

noghartt commented 1 year ago

You can't test changeStream with wiredTiger storage engine

did you mean to say ephermeralForTest? because official mongodb docs say this about Availability for Change Streams:

The replica sets and sharded clusters must use the WiredTiger storage engine. Change streams can also be used on deployments that employ MongoDB's encryption-at-rest feature.

source

Sorry, you're right. In case, we need to handle a replset instance with wiredTiger, I was wrong.

github-actions[bot] commented 1 year ago

Marking the Issue as stale, it will be closed in 7 days if no more activity is seen

github-actions[bot] commented 1 year ago

Closing the Issue because it is marked as stale