Skip to content

Commit

Permalink
json-stream reporter is incompatible with --parallel
Browse files Browse the repository at this point in the history
this could be fixed (but probably not without breaking changes), but again, `runner.total` is the issue.
  • Loading branch information
boneskull committed Apr 9, 2020
1 parent 365f4a5 commit 1f08bbe
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 35 deletions.
6 changes: 6 additions & 0 deletions lib/cli/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ exports.builder = yargs =>
);
}

if (argv.reporter === 'json-stream' && argv.parallel) {
throw createUnsupportedError(
'--reporter=json-stream is mutually exclusive with --parallel'
);
}

// load requires first, because it can impact "plugin" validation
argv.rootHooks = handleRequires(argv.require);
validatePlugin(argv, 'reporter', Mocha.reporters);
Expand Down
53 changes: 18 additions & 35 deletions test/integration/options/parallel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ describe('--parallel', function() {

describe('reporter equivalence', function() {
// each reporter name is duplicated; one is in all lower-case
// 'base' is abstract, 'html' is browser-only, and 'progress' & `markdown` are incompatible
var DENY = ['progress', 'base', 'html', 'markdown'];
// 'base' is abstract, 'html' is browser-only, others are incompatible
var DENY = ['progress', 'base', 'html', 'markdown', 'json-stream'];
Object.keys(Mocha.reporters)
.filter(function(name) {
return /^[a-z]/.test(name) && DENY.indexOf(name) === -1;
Expand Down Expand Up @@ -285,12 +285,6 @@ describe('--parallel', function() {
});
});

describe('when a single test file is run with --reporter=markdown', function() {
it('should have the same output as when run with --no-parallel', function() {
return runGenericReporterTest.call(this, 'markdown');
});
});

describe('when a single test file is run with --reporter=landing', function() {
it('should have the same output as when run with --no-parallel', function() {
return runGenericReporterTest.call(this, 'landing');
Expand Down Expand Up @@ -331,38 +325,27 @@ describe('--parallel', function() {
});
});

describe('when a single test file is run with --reporter=json', function() {
it('should have the same output as when run with --no-parallel', function() {
// this one has some timings/durations that we can safely ignore
return compareReporters.call(this, 'json').then(function(result) {
var expected = result.shift();
expected.output = JSON.parse(expected.output);
var actual = result.shift();
actual.output = JSON.parse(actual.output);
return expect(actual, 'to satisfy', {
passing: expected.passing,
failing: expected.failing,
pending: expected.pending,
code: expected.code,
output: {
stats: {
suites: expected.output.stats.suites,
tests: expected.output.stats.tests,
passes: expected.output.stats.passes,
pending: expected.output.stats.pending,
failures: expected.output.stats.failures
},
tests: expected.tests
}
});
});
describe('when a single test file is run with --reporter=json-stream', function() {
it('should fail due to incompatibility', function() {
return expect(
invokeMochaAsync(
[
require.resolve('../fixtures/options/parallel/test-a.fixture.js'),
'--reporter=json-stream',
'--parallel'
],
'pipe'
)[1],
'when fulfilled',
'to have failed'
).and('when fulfilled', 'to contain output', /mutually exclusive/);
});
});

describe('when a single test file is run with --reporter=json-stream', function() {
describe('when a single test file is run with --reporter=json', function() {
it('should have the same output as when run with --no-parallel', function() {
// this one has some timings/durations that we can safely ignore
return compareReporters.call(this, 'json-stream').then(function(result) {
return compareReporters.call(this, 'json').then(function(result) {
var expected = result.shift();
expected.output = JSON.parse(expected.output);
var actual = result.shift();
Expand Down

0 comments on commit 1f08bbe

Please sign in to comment.