量角器-trx-报告器未创建trx文件 [英] Protractor-trx-reporter not creating trx file
问题描述
我第一次与Protractor合作,并且已经为NPM安装了一些模块,用于Protractor,protractor-trx-reporter,jasmine-trx-reporter和webdriver-manager. Selenium服务器在默认的4444端口上运行,当我通过命令行在本地运行它(打开浏览器,通过测试)时,测试似乎运行良好.
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).
一切似乎都没有给出任何错误,但是我找不到由protractor-trx-reporter发布的trx文件.当我运行protractor conf.js
时,测试开始,并且命令行输出显示它正在导出trx报告程序并将输出文件设置为ProtractorTestResults.trx,但是.trx文件未显示在任何地方,因此我怀疑它没有发布文件,但不会引发错误.
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.
有什么想法,如果protractor-trx-reporter尚未导出trx文件?
Any ideas if protractor-trx-reporter hasn't exported a trx file?
这是我的配置文件和spec文件的样子(都是从Protractor和protractor-trx-reporter站点中获取的样本)
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);
});
});
推荐答案
我最终使用了jasmine-trx-reporter,这是conf.js的样子:
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));
});
}
};
这篇关于量角器-trx-报告器未创建trx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!