Files
grafana/e2e/cypress/plugins/smtpTester.js
Agnès Toulet 44a40f8e0c E2E: Add SMTP tester (#88392)
* E2E: Add SMTP tester

* fix loadlocation issue when running tests on alpine

* temporary update

* add log

* update run-suite

* Update run-suite

* Update run-suite

* Update run-suite

* Update yarn.lock

* apply suggestions + cleanup logs

* update yarn.lock & package.json

* fix swagger
2024-06-18 14:32:19 +02:00

35 lines
743 B
JavaScript

const ms = require('smtp-tester');
const PORT = 7777;
const initialize = (on, config) => {
// starts the SMTP server at localhost:7777
const mailServer = ms.init(PORT);
console.log('mail server at port %d', PORT);
let lastEmail = {};
// process all emails
mailServer.bind((addr, id, email) => {
lastEmail[email.headers.to] = email;
});
on('task', {
resetEmails(recipient) {
if (recipient) {
console.log('reset all emails for recipient %s', recipient);
delete lastEmail[recipient];
} else {
console.log('reset all emails');
lastEmail = {};
}
},
getLastEmail(email) {
return lastEmail[email] || null;
},
});
};
exports.initialize = initialize;