【问题标题】:How can I have mocha reporter for protractor?我怎样才能有量角器的摩卡记者?
【发布时间】:2015-11-12 02:52:16
【问题描述】:

我正在使用量角器 (0.22.0) 来测试我的应用程序。 这可能有一个摩卡风格的记者而不是基本的茉莉花记者吗? 现在看起来像这样:

(....F...)

我看起来更像:

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

【问题讨论】:

标签: javascript protractor mocha.js jasmine-spec-reporter


【解决方案1】:

在此处查看回复:Custom Jasmine reporter in Protractor tests

我正在使用这个模块,它运行良好:https://www.npmjs.com/package/jasmine-spec-reporter

【讨论】:

    【解决方案2】:

    查看Frameworks Protractor 文档。安装 Mocha 后,您可以在 .protractor.conf.js 文件中设置 Mocha 选项:

    mochaOpts: {
      reporter: "spec",
    }
    

    【讨论】:

    • 问题是我不想切换框架。我和茉莉花相处得很好。我只想换个记者。
    【解决方案3】:

    你可以使用tap文件。这个很不错。 https://github.com/proverma/tap-file

    【讨论】:

      【解决方案4】:

      我不确定 mocha 报告器是否与 Jasmine 一起使用,但还有一些其他 Jasmine 报告器比默认报告器工作得更好。

      您需要要求 jasmine-reporters。需要将其作为依赖项。然后,您可以在量角器配置对象内的 onPrepare 函数中调用任何 Jasmine Reporters listed here

      npm i --save-dev jasmine-reporters
      

      例如使用TapReporter。在您的 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());
        },
      

      对于 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());
        }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-12-20
        • 2019-01-01
        相关资源
        最近更新 更多