6

I'm using protractor (0.22.0) for testing my app. Is this possible to have a mocha-style reporter instead of the basic jasmine one? It currenlty looks like this:

(....F...)

And I'm looking something more like:

my set of tests 1
  my test 1-1
  my test 1-2
my set of tests 2
  my test 2-1
  my test 2-2
Bastien Caudan
  • 4,482
  • 1
  • 17
  • 29
Erem
  • 1,580
  • 3
  • 14
  • 19
  • possible duplicate of [Custom Jasmine reporter in Protractor tests](http://stackoverflow.com/questions/23677986/custom-jasmine-reporter-in-protractor-tests) – Louis Dec 23 '14 at 11:42

4 Answers4

4

Check out the Frameworks Protractor docs. Once you've installed Mocha, you can set Mocha options in your .protractor.conf.js file:

mochaOpts: {
  reporter: "spec",
}
Luke Page
  • 8,136
  • 1
  • 20
  • 22
Matthew Rankin
  • 457,139
  • 39
  • 126
  • 163
  • The thing is I don't want to switch framework. I'm doing good with Jasmine. All I want is change the reporter. – Erem May 02 '14 at 08:07
4

See the response here: Custom Jasmine reporter in Protractor tests

I'm using this module and it works perfectly: https://www.npmjs.com/package/jasmine-spec-reporter.

Community
  • 1
  • 1
Erem
  • 1,580
  • 3
  • 14
  • 19
2

You can use tap file. Its pretty good. https://github.com/proverma/tap-file

nirvanastack
  • 455
  • 2
  • 5
  • 13
2

I'm not sure if mocha reporters work with Jasmine, but there are some other Jasmine reporters that work better than the default reporter.

You need to require jasmine-reporters. It's required to have it as a dependency. Then you can call any of Jasmine Reporters listed here in your onPrepare function inside your protractor config object.

npm i --save-dev jasmine-reporters

Using TapReporter for example. Do this inside your protractor.config.js:

  onPrepare: function() {
    // The require statement must be down here, since jasmine-reporters
    // needs jasmine to be in the global and protractor does not guarantee
    // this until inside the onPrepare function.
    require('jasmine-reporters');
    jasmine.getEnv().addReporter(
      new jasmine.TapReporter());
  },

For Jasmine 2.x and Protractor >1.6

  framework: "jasmine2",

  onPrepare: function() {
    // The require statement must be down here, since jasmine-reporters
    // needs jasmine to be in the global and protractor does not guarantee
    // this until inside the onPrepare function.
    var TapReporter = require('jasmine-reporters').TapReporter;

    jasmine.getEnv().addReporter(new TeamCityReporter());
  }
Mohsen
  • 64,437
  • 34
  • 159
  • 186