@@ -2,10 +2,8 @@ import { analyzeDocuments } from '../../src';
2
2
import Ajv2020 from 'ajv/dist/2020' ;
3
3
import assert from 'assert' ;
4
4
import { ObjectId , Int32 , Double , EJSON } from 'bson' ;
5
- import { MongoCluster } from 'mongodb-runner' ;
6
5
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' ;
9
7
10
8
const bsonDocuments = [ {
11
9
_id : new ObjectId ( '67863e82fb817085a6b0ebad' ) ,
@@ -50,9 +48,9 @@ describe('Documents -> Generate schema -> Validate Documents against the schema'
50
48
} ) ;
51
49
52
50
describe ( 'Documents -> Generate schema -> Use schema in validation rule in MongoDB -> Validate documents against the schema' , function ( ) {
53
- let cluster : MongoCluster | undefined ;
54
51
let client : MongoClient ;
55
52
let db : Db ;
53
+ const cluster = mochaTestServer ( ) ;
56
54
57
55
before ( async function ( ) {
58
56
// Create the schema validation rule.
@@ -63,14 +61,7 @@ describe('Documents -> Generate schema -> Use schema in validation rule in Mongo
63
61
} ;
64
62
65
63
// 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 ;
74
65
client = new MongoClient ( connectionString ) ;
75
66
await client . connect ( ) ;
76
67
db = client . db ( 'test' ) ;
@@ -81,10 +72,7 @@ describe('Documents -> Generate schema -> Use schema in validation rule in Mongo
81
72
} ) ;
82
73
} ) ;
83
74
after ( async function ( ) {
84
- await db ?. collection ( 'books' ) . drop ( ) ;
85
75
await client ?. close ( ) ;
86
- await cluster ?. close ( ) ;
87
- cluster = undefined ;
88
76
} ) ;
89
77
90
78
it ( 'allows inserting valid documents' , async function ( ) {
0 commit comments