Skip to content

Commit

Permalink
use spec reporter in tests by default; closes #2594
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed Nov 24, 2016
1 parent 004389f commit 7a05a6c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 44 deletions.
47 changes: 15 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 \
Expand All @@ -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:
Expand All @@ -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"
Expand Down
14 changes: 8 additions & 6 deletions test/integration/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
},

Expand Down
2 changes: 1 addition & 1 deletion test/integration/hook-err.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/integration/hooks.spec.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/retries.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
1 change: 0 additions & 1 deletion test/mocha.opts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
--require should
--require ./test/setup
--reporter dot
--ui bdd
--globals okGlobalA,okGlobalB
--globals okGlobalC
Expand Down

0 comments on commit 7a05a6c

Please sign in to comment.