@@ -214,7 +214,7 @@ function build (opts = {}) {
214
214
* @oaram {object} teardown (null if not needed)
215
215
* @returns {Promise }
216
216
*/
217
- async function run ( setup , test , teardown ) {
217
+ async function run ( setup , test , teardown , stats ) {
218
218
// if we should skip a feature in the setup/teardown section
219
219
// we should skip the entire test file
220
220
const skip = getSkip ( setup ) || getSkip ( teardown )
@@ -236,11 +236,11 @@ function build (opts = {}) {
236
236
}
237
237
}
238
238
239
- if ( setup ) await exec ( 'Setup' , setup )
239
+ if ( setup ) await exec ( 'Setup' , setup , stats )
240
240
241
- await exec ( 'Test' , test )
241
+ await exec ( 'Test' , test , stats )
242
242
243
- if ( teardown ) await exec ( 'Teardown' , teardown )
243
+ if ( teardown ) await exec ( 'Teardown' , teardown , stats )
244
244
245
245
if ( isXPack ) await cleanupXPack ( )
246
246
@@ -371,9 +371,14 @@ function build (opts = {}) {
371
371
* @param {object } the action to perform
372
372
* @returns {Promise }
373
373
*/
374
- async function doAction ( action ) {
374
+ async function doAction ( action , stats ) {
375
375
const cmd = parseDo ( action )
376
- const api = delve ( client , cmd . method ) . bind ( client )
376
+ try {
377
+ var api = delve ( client , cmd . method ) . bind ( client )
378
+ } catch ( err ) {
379
+ console . error ( `\nError: Cannot find the method '${ cmd . method } ' in the client.\n` )
380
+ process . exit ( 1 )
381
+ }
377
382
378
383
const options = { ignore : cmd . params . ignore , headers : action . headers }
379
384
if ( cmd . params . ignore ) delete cmd . params . ignore
@@ -414,10 +419,12 @@ function build (opts = {}) {
414
419
warnings = warnings . filter ( h => ! h . test ( / d e f a u l t \s n u m b e r \s o f \s s h a r d s / g) )
415
420
}
416
421
422
+ stats . assertions += 1
417
423
assert . ok ( deepEqual ( warnings , action . warnings ) )
418
424
}
419
425
420
426
if ( action . catch ) {
427
+ stats . assertions += 1
421
428
assert . ok (
422
429
parseDoError ( err , action . catch ) ,
423
430
`the error should be: ${ action . catch } `
@@ -428,6 +435,7 @@ function build (opts = {}) {
428
435
response = err . body
429
436
}
430
437
} else {
438
+ stats . assertions += 1
431
439
assert . ifError ( err , `should not error: ${ cmd . method } ` , action )
432
440
response = body
433
441
}
@@ -439,7 +447,7 @@ function build (opts = {}) {
439
447
* @param {object } the actions to perform
440
448
* @returns {Promise }
441
449
*/
442
- async function exec ( name , actions ) {
450
+ async function exec ( name , actions , stats ) {
443
451
// tap.comment(name)
444
452
for ( const action of actions ) {
445
453
if ( action . skip ) {
@@ -450,7 +458,7 @@ function build (opts = {}) {
450
458
}
451
459
452
460
if ( action . do ) {
453
- await doAction ( fillStashedValues ( action . do ) )
461
+ await doAction ( fillStashedValues ( action . do ) , stats )
454
462
}
455
463
456
464
if ( action . set ) {
@@ -464,6 +472,7 @@ function build (opts = {}) {
464
472
}
465
473
466
474
if ( action . match ) {
475
+ stats . assertions += 1
467
476
const key = Object . keys ( action . match ) [ 0 ]
468
477
match (
469
478
// in some cases, the yaml refers to the body with an empty string
@@ -478,6 +487,7 @@ function build (opts = {}) {
478
487
}
479
488
480
489
if ( action . lt ) {
490
+ stats . assertions += 1
481
491
const key = Object . keys ( action . lt ) [ 0 ]
482
492
lt (
483
493
delve ( response , fillStashedValues ( key ) ) ,
@@ -486,6 +496,7 @@ function build (opts = {}) {
486
496
}
487
497
488
498
if ( action . gt ) {
499
+ stats . assertions += 1
489
500
const key = Object . keys ( action . gt ) [ 0 ]
490
501
gt (
491
502
delve ( response , fillStashedValues ( key ) ) ,
@@ -494,6 +505,7 @@ function build (opts = {}) {
494
505
}
495
506
496
507
if ( action . lte ) {
508
+ stats . assertions += 1
497
509
const key = Object . keys ( action . lte ) [ 0 ]
498
510
lte (
499
511
delve ( response , fillStashedValues ( key ) ) ,
@@ -502,6 +514,7 @@ function build (opts = {}) {
502
514
}
503
515
504
516
if ( action . gte ) {
517
+ stats . assertions += 1
505
518
const key = Object . keys ( action . gte ) [ 0 ]
506
519
gte (
507
520
delve ( response , fillStashedValues ( key ) ) ,
@@ -510,6 +523,7 @@ function build (opts = {}) {
510
523
}
511
524
512
525
if ( action . length ) {
526
+ stats . assertions += 1
513
527
const key = Object . keys ( action . length ) [ 0 ]
514
528
length (
515
529
key === '$body' || key === ''
@@ -522,6 +536,7 @@ function build (opts = {}) {
522
536
}
523
537
524
538
if ( action . is_true ) {
539
+ stats . assertions += 1
525
540
const isTrue = fillStashedValues ( action . is_true )
526
541
is_true (
527
542
delve ( response , isTrue ) ,
@@ -530,6 +545,7 @@ function build (opts = {}) {
530
545
}
531
546
532
547
if ( action . is_false ) {
548
+ stats . assertions += 1
533
549
const isFalse = fillStashedValues ( action . is_false )
534
550
is_false (
535
551
delve ( response , isFalse ) ,
0 commit comments