Custom Jasmine reporter in Protractor tests
Asked Answered
I

4

18

I can not find how to change reporter style in protractors runner using jasmine framework.

What I have right now is:

enter image description here

But I would like something more like:

enter image description here

Is there a way to add custom reporter for jasmine that would show current test running instead of DOTS and Fs?

Intercessor answered 15/5, 2014 at 12:17 Comment(0)
C
21

I am building a jasmine reporter that does exactly what you want, jasmine-spec-reporter.


To configure in protractor.conf.js:

onPrepare: function(){
    var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
    jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));
}
Cassiecassil answered 17/5, 2014 at 8:55 Comment(1)
jasmine-spec-reporter has become the industry standard way to do this.Feeling
M
4

Add the isVerbose flag to the protractor config, it's false by default:

exports.config = {
  . . .

  // Options to be passed to Jasmine-node.
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    isVerbose: true
  }
};
Miliaria answered 15/5, 2014 at 13:55 Comment(5)
This only helps partially as it is holding output till all tests end. Since I have e2e tests that run realllly long I would like to know what test has what status. Right now I found that I can add my own custom reporter and I hope to share it later..Intercessor
Would love to see how you are doing this, if you get a spare moment to share.Schlessinger
@VytautasButkus did you ever make anything to share?Surratt
@BillyMoon I did, but never to the level that it would be sharable.. Though I dropped it and used the one that suggested.Intercessor
This does not work with the protractor 2.5.1 since that is not a valid jasmine option at this time.Phosphorescent
C
4

Add this dependency to your project:
npm install jasmine-spec-reporter --save-dev

And add this to your config file:

onPrepare: function(){
    var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
    jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));
}
Communicant answered 10/5, 2017 at 10:46 Comment(0)
P
2

To extend @fer's answer:

You can add these settings to jasmineNodeOpts to both see the current test and get stack trace right when test fails:

  jasmineNodeOpts: {
    showColors: true,
    isVerbose: true,
    realtimeFailure: true,
    includeStackTrace: true,
    defaultTimeoutInterval: 30000
  },
Paving answered 8/6, 2015 at 21:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.