Protractor-trx-reporter not creating trx file

2019-04-16 02:21发布

问题:

I'm working with Protractor for the first time and I've installed some modules with NPM for protractor, protractor-trx-reporter, jasmine-trx-reporter, and webdriver-manager. Selenium server is running at the default 4444 port, and the tests seem to run fine when I run it locally through command line (opens a browser, test passes).

Everything seems to not give any errors, but I can't find the trx file published by the protractor-trx-reporter. When I run protractor conf.js, the test starts, and the command line output says that it's exporting the trx reporter and setting the output file to ProtractorTestResults.trx but a .trx file doesn't show up anywhere so I suspect it's not publishing a file but not throwing errors.

Any ideas if protractor-trx-reporter hasn't exported a trx file?

Here's what my config and spec files look like (both taken as samples from Protractor and protractor-trx-reporter sites)

    //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);
     });
 });

回答1:

I ended up using jasmine-trx-reporter, here's what the conf.js looked like:

// 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:

I think this may be the answer:

"...short term we will not add support for Jasmine 2.0. Later on maybe yes, but I can't promise you a date."

So that's upsetting. I'm having the same problem. And jasmine-trx-reporter isn't working for me either.

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