Skip to content

Commit

Permalink
docs(test-runners): update mocha example code for mongoose 5+
Browse files Browse the repository at this point in the history
  • Loading branch information
hasezoey committed Jul 18, 2024
1 parent 1310d6b commit b7b2b0b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions docs/guides/integration-examples/test-runners.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,11 @@ import mongoose from 'mongoose';
import { MongoMemoryServer } from 'mongodb-memory-server';

let mongoServer;
const opts = { useMongoClient: true }; // remove this option if you use mongoose 5 and above

before(async () => {
mongoServer = await MongoMemoryServer.create();
const mongoUri = mongoServer.getUri();
await mongoose.connect(mongoUri, opts);
await mongoose.connect(mongoUri);
});

after(async () => {
Expand All @@ -130,7 +129,7 @@ after(async () => {
describe('...', () => {
it('...', async () => {
const User = mongoose.model('User', new mongoose.Schema({ name: String }));
const cnt = await User.count();
const cnt = await User.countDocuments();
expect(cnt).to.equal(0);
});
});
Expand Down

0 comments on commit b7b2b0b

Please sign in to comment.