How can I have mocha reporter for protractor?
Asked Answered
C

4

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
Corundum answered 22/4, 2014 at 13:31 Comment(1)
possible duplicate of Custom Jasmine reporter in Protractor testsWicks
C
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.

Corundum answered 23/12, 2014 at 10:27 Comment(0)
K
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",
}
Kiangsu answered 26/4, 2014 at 11:55 Comment(1)
The thing is I don't want to switch framework. I'm doing good with Jasmine. All I want is change the reporter.Corundum
C
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.

Corundum answered 23/12, 2014 at 10:27 Comment(0)
K
2

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

Keratoid answered 23/6, 2014 at 18:18 Comment(0)
C
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());
  }
Calendra answered 22/12, 2014 at 21:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.