【问题标题】:Protractor-trx-reporter not creating trx fileProtractor-trx-reporter 没有创建 trx 文件
【发布时间】:2016-06-23 07:27:58
【问题描述】:

我是第一次使用 Protractor,我已经为 protractor、protractor-trx-reporter、jasmine-trx-reporter 和 webdriver-manager 安装了一些带有 NPM 的模块。 Selenium 服务器在默认的 4444 端口上运行,当我通过命令行在本地运行它时,测试似乎运行良好(打开浏览器,测试通过)。

一切似乎都没有报错,但是我找不到protractor-trx-reporter发布的trx文件。当我运行protractor conf.js 时,测试开始,命令行输出显示它正在导出 trx 报告器并将输出文件设置为 ProtractorTestResults.trx 但 .trx 文件没有出现在任何地方,所以我怀疑它没有发布文件但不抛出错误。

如果 protractor-trx-reporter 没有导出 trx 文件有什么想法吗?

这是我的配置和规范文件的样子(均取自 Protractor 和 protractor-trx-reporter 网站的样本)

    //conf.js
    exports.config = {
      framework: 'jasmine',
      seleniumAddress: 'http://localhost:4444/wd/hub',
      specs: ['spec.js'],
      onPrepare: function () {
           console.log('Adding TRX reporter');
        require('protractor-trx-reporter');
           jasmine.getEnv().addReporter(new jasmine.TrxReporter('ProtractorTestResults.trx'));
      }
}

 //spec.js
 describe('angularjs homepage todo list', function() {
     it('should add a todo', function() {
        browser.get('https://angularjs.org');

        element(by.model('todoList.todoText')).sendKeys('write first protractor test');
        element(by.css('[value="add"]')).click();

        var todoList = element.all(by.repeater('todo in todoList.todos'));
        expect(todoList.count()).toEqual(3);
        expect(todoList.get(2).getText()).toEqual('write first protractor test');

        // You wrote your first test, cross it off the list
        todoList.get(2).element(by.css('input')).click();
        var completedAmount = element.all(by.css('.done-true'));
        expect(completedAmount.count()).toEqual(2);
     });
 });

【问题讨论】:

  • 这个好运吗,我也有类似的问题?
  • 我实际上最终放弃了 protractor-trx-reporter 并切换到 jasmine-trx-reporter npmjs.com/package/jasmine-trx-reporter,并且效果很好。 :(
  • @Sachi 我不断收到 jasmine-trx-reporter 的 trx is not defined 错误。
  • @Defpotec2020 添加了我自己的关于我如何运行它的答案,这应该可以帮助你。
  • @sachi,我寄予厚望。当我在 groupSuitesIntoSingleFile 设置为 false 的情况下运行它时,我现在得到“找不到规范”。当我在 groupSuitesIntoSingleFile 设置为 true 的情况下运行它时出现 trx not found 错误。两种情况都没有报告。当我完全删除您的代码时,一切都运行良好(当然没有生成报告)。关于什么可能是错的任何想法?谢谢!

标签: angularjs protractor


【解决方案1】:

我最终使用了 jasmine-trx-reporter,这是 conf.js 的样子:

// conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
  directConnect: true,
  specs: ['spec.js'],
  capabilities: {
    'browserName': 'chrome'
  },
onPrepare: function () {
        var trx = require('jasmine-trx-reporter');
        return browser.getCapabilities().then(function (caps) {
        var browserName = caps.get('browserName').toUpperCase();

        var jasmineTrxConfig = {
            reportName: 'Protractor Test Results',
            folder: 'testResults',
            outputFile: 'Test.trx',
            browser: browserName,
            groupSuitesIntoSingleFile: false
        };

        jasmine.getEnv().addReporter(new trx(jasmineTrxConfig));
    });
}
};

【讨论】:

    【解决方案2】:

    我想这可能是答案:

    "...短期内我们不会添加对 Jasmine 2.0 的支持。稍后也许 是的,但我不能答应你约会。”

    所以这很令人不安。我有同样的问题。 jasmine-trx-reporter 也不适合我。

    来源:[https://github.com/hatchteam/protractor-trx-reporter/issues/2]

    【讨论】:

      猜你喜欢
      • 2023-02-13
      • 2019-09-04
      • 2017-02-22
      • 1970-01-01
      • 2017-09-21
      • 1970-01-01
      • 2015-09-01
      • 1970-01-01
      • 2018-05-18
      相关资源
      最近更新 更多