node.js - 从testcafe发送html报告的邮件,如何实现?

标签 node.js testing report nodemailer testcafe

您好,我正在为我的项目使用开源 testcafe(不是工作室),一旦我的 testcafe 测试运行,它就会创建一个 testrail-html 报告。现在我想通过电子邮件发送我收到的报告。我怎么做。我已经使用 nodemailer 并在一定程度上实现了这一点,邮件正在发送时附有报告,但是附加到邮件的 html 报告显示为空白,请你帮忙。

var mailer = require("nodemailer");
var smtpTransport = require('nodemailer-smtp-transport');

var transporter = mailer.createTransport(smtpTransport({
    host: 'mailo2.abc.com',
  }));

 // send mail with defined transport object
 var mail = {
    from: '<john.doe@abc.com>', // sender address
    to: "<john.doe@abc.com>'// list of receivers
    subject: "Report for ABC Vital Business Function", // Subject line
    html: "<b> ABC Vital Business Function Report Attached</b>", // html body

    attachments: [{
        filename: 'Report.html,
        filepath:'.. /test-reports',
    }]
}

  transporter.sendMail(mail, function(error, response){
    if(error){
        console.log(error);
    }else{
        console.log("Message sent: " + response.message);
    }

    transporter.close();
});

最佳答案

您的附件 对象看起来不正确。使用 path 属性而不是 filepath:

attachments: [{
    filename: 'Report.html',
    path: '../test-reports/Report.html',
}]

关于node.js - 从testcafe发送html报告的邮件,如何实现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59034964/

相关文章:

c# - 在 C# 中模拟非虚拟方法

php - 随着我们的生产数据库的增长,如何测试查询是否花费了更长的时间?

计算字母字符数的 Python 函数,跟踪 "e"出现的次数

javascript - Mongoose :你如何取消人口?

javascript - Hapi 在处理程序中显示 undefined variable

testing - 即使第二次迭代失败,具有多次迭代的 TFS 自动化测试也显示为已通过

c# - 如何在报表中使用表单控件属性?

c# - DataBindings.Add 使用 IEnumerable<string>

javascript - Angular $promise 不使用 defer

node.js - 为什么app.use()中的中间件没有被执行