0
我使用wdio
工具從webdriver.io npm包運行摩卡測試用例。Webdriver.io如何將數據發送到自定義記者
這裏是wdio.conf.js
部分:
var htmlReporter = require('./js/reporter/htmlReporter');
htmlReporter.reporterName = 'htmlReporter';
exports.config = {
specs: [
'./test.js'
],
reporters: [htmlReporter],
...
}
test.js: 應該發送的定製數據
describe('Test suite', function() {
// is it possible to send some data to the current test-suite?
// this.customData ?
it('Test case', function() {
// is it possible to send some data to the current test-case?
// this.customData ?
});
});
});
htmlReporter.js: 應該接收自定義數據
var htmlReporter = function(options) {
var self = this;
this.on('suite:start', function(suite) {
// how to get a custom data?
// suite.customData is undefined
});
this.on('test:pass', function(test) {
// how to get a custom data?
// suite.customData is undefined
});
...
}