Npm NodeEmailer放置在量角器config afterLaunch()块中时不发送邮件
NodeEmailer放置在量角器config afterLaunch()块中时不发送邮件。 当放置在beforeLaunch()或onPrepare()块中时,它会发送邮件 问题:在量角器测试运行完成后发送HTML邮件。一旦执行完成,框架将生成一个HTML文件。nodemailer读取html内容并发送电子邮件 config.jsNpm NodeEmailer放置在量角器config afterLaunch()块中时不发送邮件,npm,jasmine,protractor,nodemailer,Npm,Jasmine,Protractor,Nodemailer,NodeEmailer放置在量角器config afterLaunch()块中时不发送邮件。 当放置在beforeLaunch()或onPrepare()块中时,它会发送邮件 问题:在量角器测试运行完成后发送HTML邮件。一旦执行完成,框架将生成一个HTML文件。nodemailer读取html内容并发送电子邮件 config.js exports.config = { specs: ['../test_lab/execute.spec.js'], capabilities:
exports.config = {
specs: ['../test_lab/execute.spec.js'],
capabilities: {
browserName: 'chrome',
seleniumAddress: 'http://localhost:4444/wd/hub',
},
beforeLaunch: function () {
// beforeLaunch actions
},
onPrepare: function () {
// onPrepare actions
},
afterLaunch: function () {
// generate HTML report
// Send HTML Email
var htmlFilePath = '../index.html';
var htmlFileContent = String(fs.readFileSync(htmlFilePath));
sendMail.sendHTMLMail(htmlFileContent);
},
framework: 'jasmine2',
jasmineNodeOpts: {
onComplete: null,
showColors: true,
defaultTimeoutInterval: 60000
}
};
var q = require('q');
exports.config = {
specs: ['../test_lab/execute.spec.js'],
capabilities: {
browserName: 'chrome',
seleniumAddress: 'http://localhost:4444/wd/hub',
},
beforeLaunch: function () {
// beforeLaunch actions
},
onPrepare: function () {
// onPrepare actions
},
afterLaunch: function () {
return q.fcall(function () {
// generate HTML report
// Send HTML Email
var htmlFilePath = '../index.html';
var htmlFileContent = String(fs.readFileSync(htmlFilePath));
sendMail.sendHTMLMail(htmlFileContent);
}).delay(1000);
},
framework: 'jasmine2',
jasmineNodeOpts: {
onComplete: null,
showColors: true,
defaultTimeoutInterval: 60000
}
};
nodeEmailer-发送邮件助手功能
var SendMail = function () {
this.sendHTMLMail = function (htmlContent) {
var transporter = nodemailer.createTransport('smtps://testmail%40gmail.com:pwd@smtp.gmail.com');
var mailOptions = {
from: '"test mail" <testmail@gmail.com>',
to: 'testmail2@gmail.com',
subject: 'Test Report',
text: 'Test Report',
html: htmlContent
};
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
return console.log(error);
}
console.log('Mail sent: ' + info.response);
});
};
};
var SendMail=函数(){
this.sendthmlmail=函数(htmlContent){
var transporter=nodeEmailer.createTransport('smtps://testmail%40gmail.com:pwd@smtp.gmail.com),;
var mailpoptions={
发件人:“‘测试邮件’”,
致:'testmail2@gmail.com',
主题:“测试报告”,
文本:“测试报告”,
html:htmlContent
};
transporter.sendMail(邮件选项,函数(错误,信息){
如果(错误){
返回console.log(错误);
}
console.log('Mail sent:'+info.response);
});
};
};
我验证了代码是否进入sendHTML块,但transporter.sendMail()没有执行我以前也遇到过类似的问题 试试这个: config.js
exports.config = {
specs: ['../test_lab/execute.spec.js'],
capabilities: {
browserName: 'chrome',
seleniumAddress: 'http://localhost:4444/wd/hub',
},
beforeLaunch: function () {
// beforeLaunch actions
},
onPrepare: function () {
// onPrepare actions
},
afterLaunch: function () {
// generate HTML report
// Send HTML Email
var htmlFilePath = '../index.html';
var htmlFileContent = String(fs.readFileSync(htmlFilePath));
sendMail.sendHTMLMail(htmlFileContent);
},
framework: 'jasmine2',
jasmineNodeOpts: {
onComplete: null,
showColors: true,
defaultTimeoutInterval: 60000
}
};
var q = require('q');
exports.config = {
specs: ['../test_lab/execute.spec.js'],
capabilities: {
browserName: 'chrome',
seleniumAddress: 'http://localhost:4444/wd/hub',
},
beforeLaunch: function () {
// beforeLaunch actions
},
onPrepare: function () {
// onPrepare actions
},
afterLaunch: function () {
return q.fcall(function () {
// generate HTML report
// Send HTML Email
var htmlFilePath = '../index.html';
var htmlFileContent = String(fs.readFileSync(htmlFilePath));
sendMail.sendHTMLMail(htmlFileContent);
}).delay(1000);
},
framework: 'jasmine2',
jasmineNodeOpts: {
onComplete: null,
showColors: true,
defaultTimeoutInterval: 60000
}
};