Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow the random seed reproduction command to be overridden
Needed by jasmine-browser-runner, which uses the ConsoleReporter but needs
to tell the user to run a different command.
  • Loading branch information
sgravrock committed Jun 21, 2021
1 parent 00b5ef2 commit 6d31aec
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/reporters/console_reporter.js
Expand Up @@ -29,6 +29,9 @@ function ConsoleReporter() {
if (options.stackFilter) {
stackFilter = options.stackFilter;
}
if (options.randomSeedReproductionCmd) {
this.randomSeedReproductionCmd = options.randomSeedReproductionCmd;
}
};

this.jasmineStarted = function(options) {
Expand Down Expand Up @@ -99,11 +102,15 @@ function ConsoleReporter() {

if (result && result.order && result.order.random) {
print('Randomized with seed ' + result.order.seed);
print(' (jasmine --random=true --seed=' + result.order.seed + ')');
print(' (' + this.randomSeedReproductionCmd(result.order.seed) + ')');
printNewline();
}
};

this.randomSeedReproductionCmd = function(seed) {
return 'jasmine --random=true --seed=' + seed;
};

this.specDone = function(result) {
specCount++;

Expand Down
19 changes: 19 additions & 0 deletions spec/reporters/console_reporter_spec.js
Expand Up @@ -166,6 +166,25 @@ describe("ConsoleReporter", function() {
expect(this.out.getOutput()).toMatch(/Randomized with seed 12345 \(jasmine --random=true --seed=12345\)/);
});

it("allows the seed reproduction command to be overridden", function() {
var reporter = new ConsoleReporter("jasmine-some-other-tool");
reporter.setOptions({
print: this.out.print,
randomSeedReproductionCmd: function(seed) {
return `jasmine-some-other-tool --randomSeed=${seed}`;
}
});

reporter.jasmineDone({
order: {
random: true,
seed: '12345'
}
});

expect(this.out.getOutput()).toMatch(/Randomized with seed 12345 \(jasmine-some-other-tool --randomSeed=12345\)/);
});

it("reports a summary when done (singular spec and time)", function() {
var reporter = new ConsoleReporter();
reporter.setOptions({
Expand Down

0 comments on commit 6d31aec

Please sign in to comment.