Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Added mocha.opts support. Closes #31

Tj Holowaychukaec68b79c060
diff --git a/Makefile b/Makefile
index 98138ff8..d2acf3a8 100644
--- a/Makefile
+++ b/Makefile
@@ -8,29 +8,23 @@ test-all: test-bdd test-tdd test-exports test-unit test-grep
test-unit:
@./bin/mocha \
- --require should \
--reporter $(REPORTER) \
- --ui bdd \
- --growl \
$(TESTS)
test-bdd:
@./bin/mocha \
- --require should \
--reporter $(REPORTER) \
--ui bdd \
test/bdd
test-tdd:
@./bin/mocha \
- --require should \
--reporter $(REPORTER) \
--ui tdd \
test/tdd
test-exports:
@./bin/mocha \
- --require should \
--reporter $(REPORTER) \
--ui exports \
test/exports
diff --git a/bin/mocha b/bin/mocha
index 759167a4..9e367ca7 100755
--- a/bin/mocha
+++ b/bin/mocha
@@ -56,6 +56,18 @@ program.on('require', function(mod){
require(mod);
});
+// mocha.opts support
+
+try {
+ var opts = fs.readFileSync('test/mocha.opts', 'utf8');
+ opts = opts.split(/\s+/);
+ process.argv = process.argv
+ .slice(0, 2)
+ .concat(opts.concat(process.argv.slice(2)));
+} catch (err) {
+ // ignore
+}
+
// parse args
program.parse(process.argv);
diff --git a/test/mocha.opts b/test/mocha.opts
new file mode 100644
index 00000000..7104117c
--- /dev/null
+++ b/test/mocha.opts
@@ -0,0 +1,4 @@
+--require should
+--reporter dot
+--ui bdd
+--growl