Skip to content

Commit 9a98a78

Browse files
committed
fixup: use compass-test-server for mocha mongodb-runner test server cleanup instead of mongodb-runner directly
1 parent a228bbc commit 9a98a78

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

package-lock.json

Lines changed: 20 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"reservoir": "^0.1.2"
5555
},
5656
"devDependencies": {
57+
"@mongodb-js/compass-test-server": "^0.3.2",
5758
"@types/json-schema": "^7.0.15",
5859
"@types/mocha": "^10.0.1",
5960
"@types/node": "^22.13.1",
@@ -75,7 +76,6 @@
7576
"gen-esm-wrapper": "^1.1.3",
7677
"mocha": "^10.2.0",
7778
"mongodb": "^6.6.1",
78-
"mongodb-runner": "^5.8.0",
7979
"nyc": "^15.1.0",
8080
"sinon": "^19.0.2",
8181
"ts-node": "^10.9.1",

test/integration/generateAndValidate.test.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ import { analyzeDocuments } from '../../src';
22
import Ajv2020 from 'ajv/dist/2020';
33
import assert from 'assert';
44
import { ObjectId, Int32, Double, EJSON } from 'bson';
5-
import { MongoCluster } from 'mongodb-runner';
65
import { MongoClient, type Db } from 'mongodb';
7-
import path from 'path';
8-
import os from 'os';
6+
import { mochaTestServer } from '@mongodb-js/compass-test-server';
97

108
const bsonDocuments = [{
119
_id: new ObjectId('67863e82fb817085a6b0ebad'),
@@ -50,9 +48,9 @@ describe('Documents -> Generate schema -> Validate Documents against the schema'
5048
});
5149

5250
describe('Documents -> Generate schema -> Use schema in validation rule in MongoDB -> Validate documents against the schema', function() {
53-
let cluster: MongoCluster | undefined;
5451
let client: MongoClient;
5552
let db: Db;
53+
const cluster = mochaTestServer();
5654

5755
before(async function() {
5856
// Create the schema validation rule.
@@ -63,14 +61,7 @@ describe('Documents -> Generate schema -> Use schema in validation rule in Mongo
6361
};
6462

6563
// Connect to the mongodb instance.
66-
cluster = await MongoCluster.start({
67-
topology: 'standalone',
68-
tmpDir: path.join(
69-
os.tmpdir(),
70-
'mongodb-schema-test'
71-
)
72-
});
73-
const connectionString = cluster.connectionString;
64+
const connectionString = cluster().connectionString;
7465
client = new MongoClient(connectionString);
7566
await client.connect();
7667
db = client.db('test');
@@ -81,10 +72,7 @@ describe('Documents -> Generate schema -> Use schema in validation rule in Mongo
8172
});
8273
});
8374
after(async function() {
84-
await db?.collection('books').drop();
8575
await client?.close();
86-
await cluster?.close();
87-
cluster = undefined;
8876
});
8977

9078
it('allows inserting valid documents', async function() {

0 commit comments

Comments
 (0)