tscoverage/ts/npmts.tests.ts

28 lines
932 B
TypeScript
Raw Normal View History

2016-01-30 03:57:24 +00:00
/// <reference path="./index.ts" />
module NpmtsTests {
2016-01-30 04:29:54 +00:00
export var run = function() {
var done = plugins.q.defer();
2016-01-31 21:24:57 +00:00
plugins.fs.ensureDirSync(paths.testDir); //make sure that mocha has a directory to look for tests
2016-01-30 04:29:54 +00:00
plugins.beautylog.info("Now running mocha tests");
2016-01-31 21:24:57 +00:00
var mocha = new plugins.mocha(); // Instantiate a Mocha instance.
2016-01-30 03:57:24 +00:00
// Add each .js file to the mocha instance
2016-01-31 21:24:57 +00:00
plugins.fs.readdirSync(paths.testDir).filter(function(file){
2016-01-30 03:57:24 +00:00
// Only keep the .js files
return file.substr(-3) === '.js';
}).forEach(function(file){
mocha.addFile(
2016-01-31 21:24:57 +00:00
plugins.path.join(paths.testDir, file)
2016-01-30 03:57:24 +00:00
);
});
// Run the tests.
mocha.run(function(failures){
process.on('exit', function () {
process.exit(failures);
});
});
2016-01-30 04:29:54 +00:00
return done.promise;
2016-01-30 03:57:24 +00:00
}
}