Last active
January 14, 2016 23:41
-
-
Save gscoppino/8b7e6b401ab73e98d8c0 to your computer and use it in GitHub Desktop.
Karma with support for test all and test module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Assuming karma.conf.js like: | |
* ==================================== | |
* module.exports = function (config) { | |
config.set({ | |
files: [ | |
'my', | |
'required', | |
'files' | |
] | |
}); | |
}; | |
* ==================================== | |
**/ | |
// Use Minimist to parse CLI args | |
var argv = minimist(process.argv.slice(2)); | |
// Get Config | |
var KarmaSettings; | |
var KarmaStub = { | |
set: function (config) { | |
KarmaSettings = config; | |
} | |
}; | |
require('./karma.conf.js')(KarmaStub); | |
// The actual Gulp task. | |
gulp.task('test', function () { | |
if (argv.m) { | |
KarmaSettings.files.pop(); // Pop last index which should be the one including the spec files. | |
KarmaSettings.files.push(path.join('src', argv.m, '**', '*.spec.js')); | |
} else { | |
// Leave settings as is: with run all tests. | |
} | |
new KarmaServer({ | |
configFile: './karma.conf.js', | |
files: KarmaSettings.files | |
}).start(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment