Skip to content

armgit / mocha

Public Imported from GitHub
0

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

use spec reporter in tests by default; closes #2594

Christopher Hiller7a05a6c8c196
diff --git a/Makefile b/Makefile
index 611211ab..52783c8c 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,6 @@ ESLINT := "node_modules/.bin/eslint"
KARMA := "node_modules/.bin/karma"
MOCHA := "bin/mocha"
-REPORTER ?= spec
TM_BUNDLE = JavaScript\ mocha.tmbundle
SRC = $(shell find lib -name "*.js" -type f | sort)
TESTS = $(shell find test -name "*.js" -type f | sort)
@@ -55,28 +54,24 @@ test-jsapi:
test-unit:
@printf "==> [Test :: Unit]\n"
- $(MOCHA) --reporter $(REPORTER) \
- test/acceptance/*.js \
+ $(MOCHA) test/acceptance/*.js \
--growl \
test/*.js
test-integration:
@printf "==> [Test :: Integrations]\n"
$(MOCHA) --timeout 5000 \
- --reporter $(REPORTER) \
test/integration/*.js
test-compilers:
@printf "==> [Test :: Compilers]\n"
- $(MOCHA) --reporter $(REPORTER) \
- --compilers coffee:coffee-script/register,foo:./test/compiler/foo \
+ $(MOCHA) --compilers coffee:coffee-script/register,foo:./test/compiler/foo \
test/acceptance/test.coffee \
test/acceptance/test.foo
test-requires:
@printf "==> [Test :: Requires]\n"
- $(MOCHA) --reporter $(REPORTER) \
- --compilers coffee:coffee-script/register \
+ $(MOCHA) --compilers coffee:coffee-script/register \
--require test/acceptance/require/a.js \
--require test/acceptance/require/b.coffee \
--require test/acceptance/require/c.js \
@@ -85,26 +80,22 @@ test-requires:
test-bdd:
@printf "==> [Test :: BDD]\n"
- $(MOCHA) --reporter $(REPORTER) \
- --ui bdd \
+ $(MOCHA) --ui bdd \
test/acceptance/interfaces/bdd.spec
test-tdd:
@printf "==> [Test :: TDD]\n"
- $(MOCHA) --reporter $(REPORTER) \
- --ui tdd \
+ $(MOCHA) --ui tdd \
test/acceptance/interfaces/tdd.spec
test-qunit:
@printf "==> [Test :: QUnit]\n"
- $(MOCHA) --reporter $(REPORTER) \
- --ui qunit \
+ $(MOCHA) --ui qunit \
test/acceptance/interfaces/qunit.spec
test-exports:
@printf "==> [Test :: Exports]\n"
- $(MOCHA) --reporter $(REPORTER) \
- --ui exports \
+ $(MOCHA) --ui exports \
test/acceptance/interfaces/exports.spec
test-glob:
@@ -113,41 +104,33 @@ test-glob:
test-reporters:
@printf "==> [Test :: Reporters]\n"
- $(MOCHA) --reporter $(REPORTER) \
- test/reporters/*.js
+ $(MOCHA) test/reporters/*.js
test-only:
@printf "==> [Test :: Only]\n"
- $(MOCHA) --reporter $(REPORTER) \
- --ui tdd \
+ $(MOCHA) --ui tdd \
test/acceptance/misc/only/tdd.spec
- $(MOCHA) --reporter $(REPORTER) \
- --ui bdd \
+ $(MOCHA) --ui bdd \
test/acceptance/misc/only/bdd.spec
- $(MOCHA) --reporter $(REPORTER) \
- --ui qunit \
+ $(MOCHA) --ui qunit \
test/acceptance/misc/only/bdd-require.spec
test-global-only:
@printf "==> [Test :: Global Only]\n"
- $(MOCHA) --reporter $(REPORTER) \
- --ui tdd \
+ $(MOCHA) --ui tdd \
test/acceptance/misc/only/global/tdd.spec
- $(MOCHA) --reporter $(REPORTER) \
- --ui bdd \
+ $(MOCHA) --ui bdd \
test/acceptance/misc/only/global/bdd.spec
- $(MOCHA) --reporter $(REPORTER) \
- --ui qunit \
+ $(MOCHA) --ui qunit \
test/acceptance/misc/only/global/qunit.spec
test-mocha:
@printf "==> [Test :: Mocha]\n"
- $(MOCHA) --reporter $(REPORTER) \
- test/mocha
+ $(MOCHA) test/mocha
non-tty:
@printf "==> [Test :: Non-TTY]\n"
diff --git a/test/integration/helpers.js b/test/integration/helpers.js
index 7f6a608a..025770dd 100644
--- a/test/integration/helpers.js
+++ b/test/integration/helpers.js
@@ -22,20 +22,22 @@ module.exports = {
* output: '...'
* }
*
- * @param {string} fixturePath
- * @param {array} args
- * @param {function} fn
+ * @param {string} fixturePath - Path to fixture .js file
+ * @param {Array<string>} args - Extra args to mocha executable
+ * @param {Function} done - Callback
*/
- runMocha: function (fixturePath, args, fn) {
+ runMocha: function (fixturePath, args, done) {
var path;
path = resolveFixturePath(fixturePath);
args = args || [];
invokeMocha(args.concat(['-C', path]), function (err, res) {
- if (err) return fn(err);
+ if (err) {
+ return done(err);
+ }
- fn(null, getSummary(res));
+ done(null, getSummary(res));
});
},
diff --git a/test/integration/hook-err.spec.js b/test/integration/hook-err.spec.js
index fbdd7e8e..8e0896f0 100644
--- a/test/integration/hook-err.spec.js
+++ b/test/integration/hook-err.spec.js
@@ -186,7 +186,7 @@ describe('hook error handling', function () {
function run (fnPath, outputFilter) {
return function (done) {
- runMocha(fnPath, [], function (err, res) {
+ runMocha(fnPath, ['--reporter', 'dot'], function (err, res) {
assert.ifError(err);
lines = res.output
diff --git a/test/integration/hooks.spec.js b/test/integration/hooks.spec.js
index 0d31cbfd..ed3c25b2 100644
--- a/test/integration/hooks.spec.js
+++ b/test/integration/hooks.spec.js
@@ -1,13 +1,13 @@
'use strict';
var assert = require('assert');
-var run = require('./helpers').runMocha;
+var runMocha = require('./helpers').runMocha;
var splitRegExp = require('./helpers').splitRegExp;
-var args = [];
+var args = ['--reporter', 'dot'];
describe('hooks', function () {
it('are ran in correct order', function (done) {
- run('cascade.fixture.js', args, function (err, res) {
+ runMocha('cascade.fixture.js', args, function (err, res) {
var lines, expected;
assert(!err);
diff --git a/test/integration/retries.spec.js b/test/integration/retries.spec.js
index 28ed702c..9d9301ad 100644
--- a/test/integration/retries.spec.js
+++ b/test/integration/retries.spec.js
@@ -2,7 +2,7 @@
var assert = require('assert');
var helpers = require('./helpers');
-var args = [];
+var args = ['--reporter', 'dot'];
var bang = require('../../lib/reporters/base').symbols.bang;
describe('retries', function () {
diff --git a/test/mocha.opts b/test/mocha.opts
index 36146eb6..12ad9803 100644
--- a/test/mocha.opts
+++ b/test/mocha.opts
@@ -1,6 +1,5 @@
--require should
--require ./test/setup
---reporter dot
--ui bdd
--globals okGlobalA,okGlobalB
--globals okGlobalC