aboutsummaryrefslogtreecommitdiff
path: root/test/mocha.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-01-16 17:51:25 +0800
committerGitHub <noreply@github.com>2018-01-16 17:51:25 +0800
commit224c14d49d0f007af641b8c7d358814634ea7c5f (patch)
treef77f7873d8bfff989902e8692d99b162168d26e6 /test/mocha.js
parent7857354d85589aef285aac7c36c96fe4f7e2143e (diff)
downloadtracifyjs-224c14d49d0f007af641b8c7d358814634ea7c5f.tar.gz
tracifyjs-224c14d49d0f007af641b8c7d358814634ea7c5f.zip
improve `mocha` tests (#2797)
- workaround sporadic delays from Travis CI
Diffstat (limited to 'test/mocha.js')
-rw-r--r--test/mocha.js39
1 files changed, 17 insertions, 22 deletions
diff --git a/test/mocha.js b/test/mocha.js
index 411f52c5..fb8c3841 100644
--- a/test/mocha.js
+++ b/test/mocha.js
@@ -1,29 +1,24 @@
-var Mocha = require('mocha'),
- fs = require('fs'),
- path = require('path');
+var fs = require("fs");
+var Mocha = require("mocha");
+var path = require("path");
-// Instantiate a Mocha instance.
-var mocha = new Mocha({});
-
-var testDir = __dirname + '/mocha/';
-
-// Add each .js file to the mocha instance
-fs.readdirSync(testDir).filter(function(file){
- // Only keep the .js files
- return file.substr(-3) === '.js';
+// Instantiate a Mocha instance
+var mocha = new Mocha({
+ timeout: 5000
+});
+var testDir = __dirname + "/mocha/";
-}).forEach(function(file){
- mocha.addFile(
- path.join(testDir, file)
- );
+// Add each .js file to the Mocha instance
+fs.readdirSync(testDir).filter(function(file) {
+ return /\.js$/.test(file);
+}).forEach(function(file) {
+ mocha.addFile(path.join(testDir, file));
});
module.exports = function() {
mocha.run(function(failures) {
- if (failures !== 0) {
- process.on('exit', function () {
- process.exit(failures);
- });
- }
+ if (failures) process.on("exit", function() {
+ process.exit(failures);
+ });
});
-}; \ No newline at end of file
+};