Skip to content

Commit

Permalink
Added a hack procedure to remove dot reporter #8
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan committed Jun 7, 2014
1 parent 1c88b04 commit c5e5870
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,39 @@ Use it in your Protractor configuration file:
}
}

## Hack to remove protractor dot reporter

In order to remove the dot reporter, I proposed this [PR](https://github.com/juliemr/minijasminenode/pull/17).
In the meantime, you can follow these instructions to get rid of it now:

Create a file in your project, for example `spec/util/reporter-hack.js`, with this code:

var reporters = jasmine.getEnv().reporter.subReporters_;
var jasmineSpecReporter, minijasmineReporter;
for (var i = 0 ; i < reporters.length ; i++) {
if (reporters[i].callback_ !== undefined) {
minijasmineReporter = reporters[i];
}
if (reporters[i].jasmineCallback !== undefined) {
jasmineSpecReporter = reporters[i];
}
}
if (jasmineSpecReporter && minijasmineReporter) {
jasmineSpecReporter.jasmineCallback = minijasmineReporter.callback_;
reporters.splice(reporters.indexOf(minijasmineReporter), 1);
} else {
console.log('Unable to find both reporters');
console.log('jasmineSpecReporter:\n', jasmineSpecReporter);
console.log('minijasmineReporter:\n', minijasmineReporter);
}

In you protractor conf, add this file to your spec files:

specs: [
'spec/util/reporter-hack.js',
...
]

## Developement

* launch all unit tests: `npm test`
Expand Down
15 changes: 15 additions & 0 deletions spec/jasmine-spec-reporter.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,18 @@ describe 'spec reporter', ->
expect(outputs).contains /failed suite/
expect(outputs).contains /successful spec/
expect(outputs).not.contains /failed spec/


describe 'with jasmine callback hack', ->
beforeEach ->
@reporter = new jasmine.SpecReporter()
@spy = jasmine.createSpy('callback')
@reporter.jasmineCallback = @spy

it 'should call jasmine callback when runner ends', ->
new Test(@reporter, ->
@describe 'suite', ->
@it 'successful spec', ->
@passed()
)
expect(@spy).toHaveBeenCalled()
4 changes: 3 additions & 1 deletion src/jasmine-spec-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var SpecReporter = function (options) {
this.options = options || {};
this.metrics = new SpecMetrics();
this.display = new SpecDisplay(this.options);
this.jasmineCallback = null;
};

SpecReporter.prototype = {
Expand All @@ -24,10 +25,11 @@ SpecReporter.prototype = {
this.metrics.start();
},

reportRunnerResults: function () {
reportRunnerResults: function (runner) {
this.metrics.stop();
this.display.summary(this.metrics);
this.finished = true;
if(this.jasmineCallback) { this.jasmineCallback(runner); }
},

reportSuiteResults: function (suite) {
Expand Down

0 comments on commit c5e5870

Please sign in to comment.