@@ -326,8 +326,8 @@ function _testsToMocha(tests) {
326
326
}
327
327
describe ( suite . title , ( ) => {
328
328
suite . tests . forEach ( test => {
329
- if ( test . skip ) {
330
- it . skip ( test . title ) ;
329
+ if ( test . only ) {
330
+ it . only ( test . title , test . f ) ;
331
331
return ;
332
332
}
333
333
it ( test . title , test . f ) ;
@@ -433,48 +433,89 @@ function addTest(manifest, test, tests) {
433
433
test . manifest = manifest ;
434
434
const description = test_id + ' ' + ( test . purpose || test . name ) ;
435
435
436
- tests . push ( {
436
+ const _test = {
437
437
title : description ,
438
438
f : makeFn ( )
439
- } ) ;
439
+ } ;
440
+ // only based on test manifest
441
+ // skip handled via skip()
442
+ if ( 'only' in test ) {
443
+ _test . only = test . only ;
444
+ }
445
+ tests . push ( _test ) ;
440
446
441
447
function makeFn ( ) {
442
448
return async function ( ) {
443
449
const self = this ;
444
450
self . timeout ( 5000 ) ;
445
451
const testInfo = TEST_TYPES [ getJsonLdTestType ( test ) ] ;
446
452
447
- // skip unknown and explicitly skipped test types
453
+ // skip based on test manifest
454
+ if ( 'skip' in test && test . skip ) {
455
+ if ( options . verboseSkip ) {
456
+ console . log ( 'Skipping test due to manifest:' ,
457
+ { id : test [ '@id' ] , name : test . name } ) ;
458
+ }
459
+ self . skip ( ) ;
460
+ }
461
+
462
+ // skip based on unknown test type
448
463
const testTypes = Object . keys ( TEST_TYPES ) ;
449
- if ( ! isJsonLdType ( test , testTypes ) || isJsonLdType ( test , SKIP_TESTS ) ) {
450
- //const type = [].concat(
451
- // getJsonLdValues(test, '@type'),
452
- // getJsonLdValues(test, 'type')
453
- //);
454
- //console.log('Skipping test "' + test.name + '" of type: ' + type);
464
+ if ( ! isJsonLdType ( test , testTypes ) ) {
465
+ if ( options . verboseSkip ) {
466
+ const type = [ ] . concat (
467
+ getJsonLdValues ( test , '@type' ) ,
468
+ getJsonLdValues ( test , 'type' )
469
+ ) ;
470
+ console . log ( 'Skipping test due to unknown type:' ,
471
+ { id : test [ '@id' ] , name : test . name , type} ) ;
472
+ }
455
473
self . skip ( ) ;
456
474
}
457
475
476
+ // skip based on test type
477
+ if ( isJsonLdType ( test , SKIP_TESTS ) ) {
478
+ if ( options . verboseSkip ) {
479
+ const type = [ ] . concat (
480
+ getJsonLdValues ( test , '@type' ) ,
481
+ getJsonLdValues ( test , 'type' )
482
+ ) ;
483
+ console . log ( 'Skipping test due to test type:' ,
484
+ { id : test [ '@id' ] , name : test . name , type} ) ;
485
+ }
486
+ self . skip ( ) ;
487
+ }
488
+
489
+ // skip based on type info
458
490
if ( testInfo . skip && testInfo . skip . type ) {
459
- //console.log('Skipping test "' + test.name + '" of type: ' + type);
491
+ if ( options . verboseSkip ) {
492
+ console . log ( 'Skipping test due to type info:' ,
493
+ { id : test [ '@id' ] , name : test . name } ) ;
494
+ }
460
495
self . skip ( ) ;
461
496
}
462
497
498
+ // skip based on id regex
463
499
if ( testInfo . skip && testInfo . skip . idRegex ) {
464
500
testInfo . skip . idRegex . forEach ( function ( re ) {
465
501
if ( re . test ( test [ '@id' ] ) ) {
466
- //console.log('Skipping test due to id:',
467
- // {id: test['@id'] });
502
+ if ( options . verboseSkip ) {
503
+ console . log ( 'Skipping test due to id:' ,
504
+ { id : test [ '@id' ] } ) ;
505
+ }
468
506
self . skip ( ) ;
469
507
}
470
508
} ) ;
471
509
}
472
510
511
+ // skip based on description regex
473
512
if ( testInfo . skip && testInfo . skip . descriptionRegex ) {
474
513
testInfo . skip . descriptionRegex . forEach ( function ( re ) {
475
514
if ( re . test ( description ) ) {
476
- //console.log('Skipping test due to description:',
477
- // {id: test['@id'], name: test.name, description });
515
+ if ( options . verboseSkip ) {
516
+ console . log ( 'Skipping test due to description:' ,
517
+ { id : test [ '@id' ] , name : test . name , description} ) ;
518
+ }
478
519
self . skip ( ) ;
479
520
}
480
521
} ) ;
@@ -490,8 +531,10 @@ function addTest(manifest, test, tests) {
490
531
skipModes = testInfo . skip . processingMode ;
491
532
}
492
533
if ( skipModes . indexOf ( pm ) !== - 1 ) {
493
- //console.log('Skipping test due to processingMode:',
494
- // {id: test['@id'], name: test.name, processingMode: pm });
534
+ if ( options . verboseSkip ) {
535
+ console . log ( 'Skipping test due to processingMode:' ,
536
+ { id : test [ '@id' ] , name : test . name , processingMode : pm } ) ;
537
+ }
495
538
self . skip ( ) ;
496
539
}
497
540
} ) ;
@@ -505,8 +548,10 @@ function addTest(manifest, test, tests) {
505
548
skipVersions = testInfo . skip . specVersion ;
506
549
}
507
550
if ( skipVersions . indexOf ( sv ) !== - 1 ) {
508
- //console.log('Skipping test due to specVersion:',
509
- // {id: test['@id'], name: test.name, specVersion: sv });
551
+ if ( options . verboseSkip ) {
552
+ console . log ( 'Skipping test due to specVersion:' ,
553
+ { id : test [ '@id' ] , name : test . name , specVersion : sv } ) ;
554
+ }
510
555
self . skip ( ) ;
511
556
}
512
557
} ) ;
0 commit comments