File tree Expand file tree Collapse file tree 4 files changed +44
-1
lines changed Expand file tree Collapse file tree 4 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -77,3 +77,4 @@ module.exports.before = runner.addBeforeHook.bind(runner);
77
77
module . exports . after = runner . addAfterHook . bind ( runner ) ;
78
78
module . exports . beforeEach = runner . addBeforeEachHook . bind ( runner ) ;
79
79
module . exports . afterEach = runner . addAfterEachHook . bind ( runner ) ;
80
+ module . exports . skip = runner . addSkippedTest . bind ( runner ) ;
Original file line number Diff line number Diff line change @@ -39,6 +39,11 @@ x.test = function (props) {
39
39
return ;
40
40
}
41
41
42
+ if ( props . skip ) {
43
+ log . write ( ' ' + chalk . cyan ( '- ' + props . title ) ) ;
44
+ return ;
45
+ }
46
+
42
47
// if (runner.stats.testCount === 1) {
43
48
// return;
44
49
// }
Original file line number Diff line number Diff line change @@ -90,7 +90,19 @@ Runner.prototype.addAfterEachHook = function (title, cb) {
90
90
} ) ;
91
91
} ;
92
92
93
+ Runner . prototype . addSkippedTest = function ( title , cb ) {
94
+ var test = new Test ( title , cb ) ;
95
+ test . skip = true ;
96
+
97
+ this . tests . concurrent . push ( test ) ;
98
+ } ;
99
+
93
100
Runner . prototype . _runTestWithHooks = function ( test ) {
101
+ if ( test . skip ) {
102
+ this . _addTestResult ( test ) ;
103
+ return Promise . resolve ( ) ;
104
+ }
105
+
94
106
var beforeHooks = this . tests . beforeEach . map ( function ( hook ) {
95
107
var title = hook . title || 'beforeEach for "' + test . title + '"' ;
96
108
hook = new Test ( title , hook . fn ) ;
@@ -162,7 +174,8 @@ Runner.prototype._addTestResult = function (test) {
162
174
duration : test . duration ,
163
175
title : test . title ,
164
176
error : test . assertError ,
165
- type : test . type
177
+ type : test . type ,
178
+ skip : test . skip
166
179
} ;
167
180
168
181
this . results . push ( props ) ;
Original file line number Diff line number Diff line change @@ -857,6 +857,30 @@ test('test types and titles', function (t) {
857
857
runner . run ( ) . then ( t . end ) ;
858
858
} ) ;
859
859
860
+ test ( 'skip test' , function ( t ) {
861
+ t . plan ( 3 ) ;
862
+
863
+ var runner = new Runner ( ) ;
864
+ var arr = [ ] ;
865
+
866
+ runner . addTest ( function ( a ) {
867
+ arr . push ( 'a' ) ;
868
+ a . end ( ) ;
869
+ } ) ;
870
+
871
+ runner . addSkippedTest ( function ( a ) {
872
+ arr . push ( 'b' ) ;
873
+ a . end ( ) ;
874
+ } ) ;
875
+
876
+ runner . run ( ) . then ( function ( ) {
877
+ t . is ( runner . stats . testCount , 1 ) ;
878
+ t . is ( runner . stats . passCount , 1 ) ;
879
+ t . same ( arr , [ 'a' ] ) ;
880
+ t . end ( ) ;
881
+ } ) ;
882
+ } ) ;
883
+
860
884
test ( 'ES2015 support' , function ( t ) {
861
885
t . plan ( 1 ) ;
862
886
You can’t perform that action at this time.
0 commit comments