@@ -186,6 +186,9 @@ function runTestSuiteTest(testData, context) {
186
186
Object . assign ( { monitorCommands : true } , testData . clientOptions )
187
187
) ;
188
188
189
+ // test-specific client options
190
+ clientOptions . autoReconnect = false ;
191
+
189
192
return MongoClient . connect ( context . url , clientOptions ) . then ( client => {
190
193
context . testClient = client ;
191
194
client . on ( 'commandStarted' , event => {
@@ -438,16 +441,40 @@ function testOperation(operation, obj, context) {
438
441
}
439
442
440
443
if ( operation . result ) {
441
- if ( operation . result . errorContains || operation . result . errorCodeName ) {
444
+ const result = operation . result ;
445
+
446
+ if (
447
+ result . errorContains ||
448
+ result . errorCodeName ||
449
+ result . errorLabelsContain ||
450
+ result . errorLabelsOmit
451
+ ) {
442
452
return opPromise
443
453
. then ( ( ) => {
444
454
throw new Error ( 'expected an error!' ) ;
445
455
} )
446
456
. catch ( err => {
457
+ const errorContains = result . errorContains ;
458
+ const errorCodeName = result . errorCodeName ;
459
+ const errorLabelsContain = result . errorLabelsContain ;
460
+ const errorLabelsOmit = result . errorLabelsOmit ;
461
+
462
+ if ( errorLabelsContain ) {
463
+ expect ( err . errorLabels ) . to . include . members ( errorLabelsContain ) ;
464
+ }
465
+
466
+ if ( errorLabelsOmit ) {
467
+ if ( err . errorLabels && Array . isArray ( err . errorLabels ) && err . errorLabels . length !== 0 ) {
468
+ expect ( err . errorLabels ) . to . not . include . members ( errorLabelsOmit ) ;
469
+ }
470
+ }
471
+
447
472
if ( operation . result . errorContains ) {
448
- expect ( err ) . to . match ( new RegExp ( operation . result . errorContains , 'i' ) ) ;
449
- } else {
450
- expect ( err . codeName ) . to . equal ( operation . result . errorCodeName ) ;
473
+ expect ( err ) . to . match ( new RegExp ( errorContains , 'i' ) ) ;
474
+ }
475
+
476
+ if ( errorCodeName ) {
477
+ expect ( err . codeName ) . to . equal ( errorCodeName ) ;
451
478
}
452
479
} ) ;
453
480
}
0 commit comments