【发布时间】:2019-07-12 17:52:08
【问题描述】:
我想为我的夜间测试套件在“after”全局中运行一个 nodemailer js 文件。这是我现在运行的命令,用于启动示例测试并让它使用“nightwatch-html-reporter”生成 html 报告。
node_modules/.bin/nightwatch --config nightwatch.conf.BASIC.js --test test\e2e\search.js --reporter ./reports/reporter.js
这个想法是,在运行和创建此报告后,我想立即通过电子邮件发送它。
这是我在上述命令之后在 powershell 中使用的命令,用于使用“nodemailer”和“nodemailer-sendgrid-transport”通过电子邮件发送报告
node reports/nodemailer.js
我尝试将 nodemailer.js 中的代码合并到 report.js 文件中,但它会干扰报告的创建。生成报告后如何自动将其发送至电子邮件。
在我的 globals.js 文件中是否有办法像这样在 'after' 命令中触发此节点命令?:
module.exports = {
// this controls whether to abort the test execution when an assertion failed and skip the rest
// it's being used in waitFor commands and expect assertions
abortOnAssertionFailure: true,
...
'default': {
myGlobal: function () {
return 'I\'m a method';
}
},
'emailReport': { <-- HERE???
myGlobal: function () {
node reports/nodemailer.js <--???
}
},
...
after(cb) {
this.emailReport.myGlobal(); <---???
cb();
},
afterEach(browser, cb) {
browser.perform(function () {
//console.log('GLOBAL afterEach')
cb();
});
},
reporter(results, cb) { <-- or in here somehow???
cb();
}
};
【问题讨论】:
标签: node.js nightwatch.js