Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds tests for loading reporters w/ relative/absolute paths #2773

Merged
merged 3 commits into from Apr 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions test/integration/fixtures/simple-reporter.js
@@ -0,0 +1,26 @@
var baseReporter = require('../../../lib/reporters/base');
module.exports = simplereporter;

function simplereporter (runner) {
baseReporter.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');
});
}
27 changes: 27 additions & 0 deletions test/integration/reporters.spec.js
Expand Up @@ -60,4 +60,31 @@ 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);
assert.equal(result.code, 0);
done();
});
});

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

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

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