garris / BackstopJS

Catch CSS curve balls.
http://backstopjs.org
MIT License
6.71k stars 603 forks source link

(Feature) Send email after test is complete #1494

Closed ms-carterk closed 1 year ago

ms-carterk commented 1 year ago

I want to be able to walk away from my desk while the test runs. Is it possible to integrate a way to send an email after the test is done?

garris commented 1 year ago

You could build this fairly easily in node env. See the integration section in the docs where you can do this...

backstop('test')
  .then(() => {
    // test successful
  }).catch(() => {
    // test failed
  });
ms-carterk commented 1 year ago

thank you!

ms-carterk commented 1 year ago

const gulp = require("gulp"); const backstop = require("backstopjs"); const nodemailer = require("nodemailer");

const transporter = nodemailer.createTransport({ service: "gmail", // e.g., 'gmail' auth: { user: "sending@email.com", pass: "password", }, }); gulp.task("backstop-test", function () { return backstop("test") .then(() => { console.log("Test successful"); const mailOptions = { from: "sending@email.com", to: "to@email.com", subject: "BackstopJS Test Successful", text: "The BackstopJS test was successful.", html: "

The BackstopJS test was successful.

", }; return transporter.sendMail(mailOptions); }) .catch(() => { console.log("Test failed"); const mailOptions = { from: "sending@email.com", to: "to@email.com", subject: "BackstopJS Test Failed", text: "The BackstopJS test failed.", html: "

The BackstopJS test failed.

", }; return transporter.sendMail(mailOptions); }); });