简体   繁体   English

我怎么能有mocha记者的量角器?

[英]How can I have mocha reporter for protractor?

I'm using protractor (0.22.0) for testing my app. 我正在使用量角器(0.22.0)测试我的应用程序。 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

See the response here: Custom Jasmine reporter in Protractor tests 请参阅此处的回复: Protractor测试中的自定义Jasmine记者

I'm using this module and it works perfectly: https://www.npmjs.com/package/jasmine-spec-reporter . 我正在使用这个模块,它运行良好: https//www.npmjs.com/package/jasmine-spec-reporter

Check out the Frameworks Protractor docs. 查看Frameworks Protractor文档。 Once you've installed Mocha, you can set Mocha options in your .protractor.conf.js file: 一旦安装了Mocha,就可以在.protractor.conf.js文件中设置Mocha选项:

mochaOpts: {
  reporter: "spec",
}

You can use tap file. 您可以使用点按文件。 Its pretty good. 这是相当不错。 https://github.com/proverma/tap-file https://github.com/proverma/tap-file

I'm not sure if mocha reporters work with Jasmine, but there are some other Jasmine reporters that work better than the default reporter. 我不确定摩卡记者是否与Jasmine合作,但还有一些其他Jasmine记者比默认记者更好。

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. 然后,您可以在量角器配置对象中的onPrepare函数中调用此处列出的任何Jasmine Reporter

npm i --save-dev jasmine-reporters

Using TapReporter for example. TapReporter为例。 Do this inside your protractor.config.js : 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 对于Jasmine 2.x和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());
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM