From c5e58709b48323917aebde176d156e42afdccd9b Mon Sep 17 00:00:00 2001 From: Bastien Caudan Date: Sat, 7 Jun 2014 11:48:30 +0200 Subject: [PATCH] Added a hack procedure to remove dot reporter #8 --- README.md | 33 ++++++++++++++++++++++++++ spec/jasmine-spec-reporter.spec.coffee | 15 ++++++++++++ src/jasmine-spec-reporter.js | 4 +++- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f8d4ee8b..232ce3ad 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/spec/jasmine-spec-reporter.spec.coffee b/spec/jasmine-spec-reporter.spec.coffee index 7bbd15b7..f1d9785a 100644 --- a/spec/jasmine-spec-reporter.spec.coffee +++ b/spec/jasmine-spec-reporter.spec.coffee @@ -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() diff --git a/src/jasmine-spec-reporter.js b/src/jasmine-spec-reporter.js index 27d6a23e..782b88bf 100644 --- a/src/jasmine-spec-reporter.js +++ b/src/jasmine-spec-reporter.js @@ -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 = { @@ -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) {