Does anyone know how to test mail-notifier module in nodejs? I want to test the logic inside n.on():
const notifier = require('mail-notifier');
const imap = {
user: 'mailId',
password: 'password',
host: 'host',
port: 'port',
tls: true,
tlsOptions: { rejectUnauthorized: false }
};
const n = notifier(imap);
n.on('mail', async function (mail) {
console.log('mail:', mail);
}).start();
Assuming you are just looking to test that the callback is triggered then you can use a mock function e.g.