File tree 2 files changed +22
-1
lines changed 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -155,11 +155,26 @@ function addFiles(kind) {
155
155
var jasmineRunner = this ;
156
156
var fileArr = this [ kind ] ;
157
157
158
+ var includeFiles = [ ] ;
159
+ var excludeFiles = [ ] ;
158
160
files . forEach ( function ( file ) {
161
+ if ( file . startsWith ( '!' ) ) {
162
+ var excludeFile = file . substring ( 1 ) ;
163
+ if ( ! ( path . isAbsolute && path . isAbsolute ( excludeFile ) ) ) {
164
+ excludeFile = path . join ( jasmineRunner . projectBaseDir , jasmineRunner . specDir , excludeFile ) ;
165
+ }
166
+
167
+ excludeFiles . push ( excludeFile ) ;
168
+ } else {
169
+ includeFiles . push ( file ) ;
170
+ }
171
+ } ) ;
172
+
173
+ includeFiles . forEach ( function ( file ) {
159
174
if ( ! ( path . isAbsolute && path . isAbsolute ( file ) ) ) {
160
175
file = path . join ( jasmineRunner . projectBaseDir , jasmineRunner . specDir , file ) ;
161
176
}
162
- var filePaths = glob . sync ( file ) ;
177
+ var filePaths = glob . sync ( file , { ignore : excludeFiles } ) ;
163
178
filePaths . forEach ( function ( filePath ) {
164
179
if ( fileArr . indexOf ( filePath ) === - 1 ) {
165
180
fileArr . push ( filePath ) ;
Original file line number Diff line number Diff line change @@ -63,6 +63,12 @@ describe('Jasmine', function() {
63
63
expect ( this . testJasmine . specFiles . map ( basename ) ) . toEqual ( [ 'command_spec.js' , 'jasmine_spec.js' ] ) ;
64
64
} ) ;
65
65
66
+ it ( 'add spec files with excluded files' , function ( ) {
67
+ expect ( this . testJasmine . specFiles ) . toEqual ( [ ] ) ;
68
+ this . testJasmine . addSpecFiles ( [ 'spec/*.js' , '!spec/command*' ] ) ;
69
+ expect ( this . testJasmine . specFiles . map ( basename ) ) . toEqual ( [ 'jasmine_spec.js' ] ) ;
70
+ } ) ;
71
+
66
72
it ( 'add spec files with glob pattern to existings files' , function ( ) {
67
73
var aFile = path . join ( this . testJasmine . projectBaseDir , this . testJasmine . specDir , 'spec/command_spec.js' ) ;
68
74
this . testJasmine . specFiles = [ aFile , 'b' ] ;
You can’t perform that action at this time.
0 commit comments