@@ -307,6 +307,10 @@ describe('CRUD API explain option', function () {
307
307
} ;
308
308
const commands : ExplainStartedEvent [ ] = [ ] ;
309
309
310
+ function test ( description : string , f : ( ) => Promise < void > ) {
311
+ return it ( description , { requires : { mongodb : '>=4.4' } } , f ) ;
312
+ }
313
+
310
314
beforeEach ( async function ( ) {
311
315
client = this . configuration . newClient ( { } , { monitorCommands : true } ) ;
312
316
client . on ( 'commandStarted' , filterForCommands ( 'explain' , commands ) ) ;
@@ -330,13 +334,13 @@ describe('CRUD API explain option', function () {
330
334
331
335
describe ( 'when a cursor api is being explained' , function ( ) {
332
336
describe ( 'when timeoutMS is provided' , function ( ) {
333
- it ( 'the explain command respects timeoutMS' , async function ( ) {
337
+ test ( 'the explain command respects timeoutMS' , async function ( ) {
334
338
const cursor = client . db ( 'foo' ) . collection ( 'bar' ) . find ( { } , { timeoutMS : 1000 } ) ;
335
339
const timeout = await cursor . explain ( { verbosity : 'queryPlanner' } ) . catch ( e => e ) ;
336
340
expect ( timeout ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
337
341
} ) ;
338
342
339
- it ( 'the explain command has the calculated maxTimeMS value attached' , async function ( ) {
343
+ test ( 'the explain command has the calculated maxTimeMS value attached' , async function ( ) {
340
344
const cursor = client . db ( 'foo' ) . collection ( 'bar' ) . find ( { } , { timeoutMS : 1000 } ) ;
341
345
const timeout = await cursor . explain ( { verbosity : 'queryPlanner' } ) . catch ( e => e ) ;
342
346
expect ( timeout ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
@@ -350,7 +354,7 @@ describe('CRUD API explain option', function () {
350
354
expect ( maxTimeMS ) . to . be . a ( 'number' ) ;
351
355
} ) ;
352
356
353
- it ( 'the explained command does not have a maxTimeMS value attached' , async function ( ) {
357
+ test ( 'the explained command does not have a maxTimeMS value attached' , async function ( ) {
354
358
const cursor = client . db ( 'foo' ) . collection ( 'bar' ) . find ( { } , { timeoutMS : 1000 } ) ;
355
359
const timeout = await cursor . explain ( { verbosity : 'queryPlanner' } ) . catch ( e => e ) ;
356
360
expect ( timeout ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
@@ -368,7 +372,7 @@ describe('CRUD API explain option', function () {
368
372
} ) ;
369
373
370
374
describe ( 'when timeoutMS and maxTimeMS are both provided' , function ( ) {
371
- it ( 'an error is thrown indicating incompatibility of those options' , async function ( ) {
375
+ test ( 'an error is thrown indicating incompatibility of those options' , async function ( ) {
372
376
const cursor = client . db ( 'foo' ) . collection ( 'bar' ) . find ( { } , { timeoutMS : 1000 } ) ;
373
377
const error = await cursor
374
378
. explain ( { verbosity : 'queryPlanner' , maxTimeMS : 1000 } )
@@ -380,7 +384,7 @@ describe('CRUD API explain option', function () {
380
384
381
385
describe ( 'when a non-cursor api is being explained' , function ( ) {
382
386
describe ( 'when timeoutMS is provided' , function ( ) {
383
- it ( 'the explain command respects timeoutMS' , async function ( ) {
387
+ test ( 'the explain command respects timeoutMS' , async function ( ) {
384
388
const timeout = await client
385
389
. db ( 'foo' )
386
390
. collection ( 'bar' )
@@ -395,7 +399,7 @@ describe('CRUD API explain option', function () {
395
399
expect ( timeout ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
396
400
} ) ;
397
401
398
- it ( 'the explain command has the calculated maxTimeMS value attached' , async function ( ) {
402
+ test ( 'the explain command has the calculated maxTimeMS value attached' , async function ( ) {
399
403
const timeout = await client
400
404
. db ( 'foo' )
401
405
. collection ( 'bar' )
@@ -419,7 +423,7 @@ describe('CRUD API explain option', function () {
419
423
expect ( maxTimeMS ) . to . be . a ( 'number' ) ;
420
424
} ) ;
421
425
422
- it ( 'the explained command does not have a maxTimeMS value attached' , async function ( ) {
426
+ test ( 'the explained command does not have a maxTimeMS value attached' , async function ( ) {
423
427
const timeout = await client
424
428
. db ( 'foo' )
425
429
. collection ( 'bar' )
@@ -447,7 +451,7 @@ describe('CRUD API explain option', function () {
447
451
} ) ;
448
452
449
453
describe ( 'when timeoutMS and maxTimeMS are both provided' , function ( ) {
450
- it ( 'an error is thrown indicating incompatibility of those options' , async function ( ) {
454
+ test ( 'an error is thrown indicating incompatibility of those options' , async function ( ) {
451
455
const error = await client
452
456
. db ( 'foo' )
453
457
. collection ( 'bar' )
@@ -466,7 +470,7 @@ describe('CRUD API explain option', function () {
466
470
} ) ;
467
471
468
472
describe ( 'when find({}, { explain: ...}) is used with timeoutMS' , function ( ) {
469
- it ( 'an error is thrown indicating that explain is not supported with timeoutMS for this API' , async function ( ) {
473
+ test ( 'an error is thrown indicating that explain is not supported with timeoutMS for this API' , async function ( ) {
470
474
const error = await client
471
475
. db ( 'foo' )
472
476
. collection ( 'bar' )
@@ -487,7 +491,7 @@ describe('CRUD API explain option', function () {
487
491
} ) ;
488
492
489
493
describe ( 'when aggregate({}, { explain: ...}) is used with timeoutMS' , function ( ) {
490
- it ( 'an error is thrown indicating that explain is not supported with timeoutMS for this API' , async function ( ) {
494
+ test ( 'an error is thrown indicating that explain is not supported with timeoutMS for this API' , async function ( ) {
491
495
const error = await client
492
496
. db ( 'foo' )
493
497
. collection ( 'bar' )
@@ -506,15 +510,15 @@ describe('CRUD API explain option', function () {
506
510
507
511
describe ( 'fluent api timeoutMS precedence and inheritance' , function ( ) {
508
512
describe ( 'find({}, { timeoutMS }).explain()' , function ( ) {
509
- it ( 'respects the timeoutMS from the find options' , async function ( ) {
513
+ test ( 'respects the timeoutMS from the find options' , async function ( ) {
510
514
const cursor = client . db ( 'foo' ) . collection ( 'bar' ) . find ( { } , { timeoutMS : 1000 } ) ;
511
515
const timeout = await cursor . explain ( { verbosity : 'queryPlanner' } ) . catch ( e => e ) ;
512
516
expect ( timeout ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
513
517
} ) ;
514
518
} ) ;
515
519
516
520
describe ( 'find().explain({}, { timeoutMS })' , function ( ) {
517
- it ( 'respects the timeoutMS from the explain helper' , async function ( ) {
521
+ test ( 'respects the timeoutMS from the explain helper' , async function ( ) {
518
522
const cursor = client . db ( 'foo' ) . collection ( 'bar' ) . find ( ) ;
519
523
const timeout = await cursor
520
524
. explain ( { verbosity : 'queryPlanner' } , { timeoutMS : 1000 } )
@@ -524,7 +528,7 @@ describe('CRUD API explain option', function () {
524
528
} ) ;
525
529
526
530
describe ( 'find({}, { timeoutMS} ).explain({}, { timeoutMS })' , function ( ) {
527
- it ( 'the timeoutMS from the explain helper has precedence' , async function ( ) {
531
+ test ( 'the timeoutMS from the explain helper has precedence' , async function ( ) {
528
532
const cursor = client . db ( 'foo' ) . collection ( 'bar' ) . find ( { } , { timeoutMS : 2000 } ) ;
529
533
const timeout = await cursor
530
534
. explain ( { verbosity : 'queryPlanner' } , { timeoutMS : 1000 } )
@@ -534,15 +538,15 @@ describe('CRUD API explain option', function () {
534
538
} ) ;
535
539
536
540
describe ( 'aggregate([], { timeoutMS }).explain()' , function ( ) {
537
- it ( 'respects the timeoutMS from the find options' , async function ( ) {
541
+ test ( 'respects the timeoutMS from the find options' , async function ( ) {
538
542
const cursor = client . db ( 'foo' ) . collection ( 'bar' ) . aggregate ( [ ] , { timeoutMS : 1000 } ) ;
539
543
const timeout = await cursor . explain ( { verbosity : 'queryPlanner' } ) . catch ( e => e ) ;
540
544
expect ( timeout ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
541
545
} ) ;
542
546
} ) ;
543
547
544
548
describe ( 'aggregate([], { timeoutMS })' , function ( ) {
545
- it ( 'respects the timeoutMS from the explain helper' , async function ( ) {
549
+ test ( 'respects the timeoutMS from the explain helper' , async function ( ) {
546
550
const cursor = client . db ( 'foo' ) . collection ( 'bar' ) . aggregate ( ) ;
547
551
const timeout = await cursor
548
552
. explain ( { verbosity : 'queryPlanner' } , { timeoutMS : 1000 } )
@@ -552,7 +556,7 @@ describe('CRUD API explain option', function () {
552
556
} ) ;
553
557
554
558
describe ( 'aggregate([], { timeoutMS} ).explain({}, { timeoutMS })' , function ( ) {
555
- it ( 'the timeoutMS from the explain helper has precedence' , async function ( ) {
559
+ test ( 'the timeoutMS from the explain helper has precedence' , async function ( ) {
556
560
const cursor = client . db ( 'foo' ) . collection ( 'bar' ) . aggregate ( [ ] , { timeoutMS : 2000 } ) ;
557
561
const timeout = await cursor
558
562
. explain ( { verbosity : 'queryPlanner' } , { timeoutMS : 1000 } )
0 commit comments