Skip to content

Commit

Permalink
Adds tests for loading reporters w/ relative/absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
sul4bh committed Apr 20, 2017
1 parent 73929ad commit 555a90a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/integration/fixtures/simple-reporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const mocha = require('mocha');
module.exports = simplereporter;

function simplereporter (runner) {
mocha.reporters.Base.call(this, runner);

runner.on('suite', function (suite) {
console.log('on(\'suite\') called');
});

runner.on('fail', function (test, err) {
console.log('on(\'fail\') called');
});

runner.on('pass', function (test) {
console.log('on(\'pass\') called');
});

runner.on('test end', function (test, err) {
console.log('on(\'test end\') called');
});

runner.on('end', function () {
console.log('on(\'end\') called');
});
}
25 changes: 25 additions & 0 deletions test/integration/reporters.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,29 @@ describe('reporters', function () {
});
});
});

describe('loader', function () {
it('loads a reporter from a path relative to the current working directory', function (done) {
var reporterAtARelativePath = 'test/integration/fixtures/simple-reporter.js';

var args = ['--reporter=' + reporterAtARelativePath];

run('passing.fixture.js', args, function (err, result) {
assert(!err);
done();
});
});

it('loads a reporter from an absolute path', function (done) {
// Generates an absolute path string
var reporterAtAnAbsolutePath = process.cwd() + 'test/integration/fixtures/simple-reporter.js';

var args = ['--reporter=' + reporterAtAnAbsolutePath];

run('passing.fixture.js', args, function (err, result) {
assert(!err);
done();
});
});
});
});

0 comments on commit 555a90a

Please sign in to comment.