I am working on setting up test runner tasks for our project and ran into something unexpected. Our task wasn't getting any of the files using the below pattern:
'/tests/**/*.spec.js'
Our directory structure is like this:
--Scripts
--app
--tests
-test.spec.js
-gulp.js
-karma.conf.js
etc.
However, this was bring forward 0 test cases. When I changed the pattern to this, instead:
'/tests/*.spec.js'
Then it works as expected. Now, I know the /**/*spec.js
is a pattern for "files that end with 'spec.js' in zero or more sub directories". But, it feels like there should be a simple pattern to say "all files that end with 'spec.js' in this directory and in zero or more sub-directories". Otherwise, I know have to use both patterns if my structure looks like this:
--Scripts
--app
--tests
-test.spec.js
--subTests
-test2.spec.js
-gulp.js
-karma.conf.js
etc.
The above would require my gulp task to look something like below:
gulp.task('unit-test', ['lint'], function (done) {
gulputil.log('Running unit tests...');
//return gulp.src(testFilesDirect).pipe(jasmine({ verbose: true, includeStackTrace: true }));
new KarmaServer({
configFile: __dirname + '/karma.conf.js',
files: ['/tests/*.spec.js', '/tests/**/*.spec.js'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
}, done).start();
});
Is that correct or am I missing something fundamental that wouldn't require two test patterns?
There is another article that talks about symlinks here: Gulp - Target all files in a folder and its subfolders
But that seems to be directed towards a more localized setup whereas my situation needs to be part of an automated build system, additionally, those solutions involved Linux or Mac and our systems are Windows based.
'/scripts/**/*.spec.js'
. This is onnode v5.6.0
andgulp 3.9.0
– Anapest