Skip to content

Commit

Permalink
fix: don't show seed when shuffle was not enabled (#662)
Browse files Browse the repository at this point in the history
Previously the seed was always shown in the output, even when the order
was not randomized. This could be confusing. With this change, the seed
will only be included in the output if shuffle was enabled.
  • Loading branch information
rmehner authored and geek committed Nov 11, 2016
1 parent 9c88e33 commit 63e649e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/reporters/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ internals.Reporter.prototype.end = function (notebook) {
}
}

if (notebook.seed) {
if (notebook.shuffle) {
output += 'Randomized with seed: ' + notebook.seed + '. Use --shuffle --seed ' + notebook.seed + ' to run tests in same order again.\n';
}

Expand Down
1 change: 1 addition & 0 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ exports.report = function (scripts, options, callback) {

if (settings.shuffle) {
result.seed = settings.seed;
result.shuffle = true;
}

return next(null, result);
Expand Down
20 changes: 19 additions & 1 deletion test/reporters.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ describe('Reporter', () => {
const reporter = Reporters.generate({ reporter: 'console' });
const notebook = {
tests: [],
seed: 1234
seed: 1234,
shuffle: true
};

reporter.finalize(notebook, (err, code, output) => {
Expand All @@ -342,6 +343,23 @@ describe('Reporter', () => {
});
});

it('does not include the seed if shuffle was not active', (done) => {

const reporter = Reporters.generate({ reporter: 'console' });
const notebook = {
tests: [],
seed: 1234
};

reporter.finalize(notebook, (err, code, output) => {

expect(output).to.not.contain('1234');
expect(output).to.not.contain('seed');
expect(err).not.to.exist();
done();
});
});

describe('console', () => {

it('generates a report', (done) => {
Expand Down

0 comments on commit 63e649e

Please sign in to comment.