@@ -2,10 +2,8 @@ import { analyzeDocuments } from '../../src';
22import Ajv2020 from 'ajv/dist/2020' ;
33import assert from 'assert' ;
44import { ObjectId , Int32 , Double , EJSON } from 'bson' ;
5- import { MongoCluster } from 'mongodb-runner' ;
65import { 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
108const bsonDocuments = [ {
119 _id : new ObjectId ( '67863e82fb817085a6b0ebad' ) ,
@@ -50,9 +48,9 @@ describe('Documents -> Generate schema -> Validate Documents against the schema'
5048} ) ;
5149
5250describe ( '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