如何在 Velocity 端到端测试中测试电子邮件?

How do I test emailing in a Velocity end-to-end test?

我正致力于在 Velocity 中编写端到端(客户端)测试,并试图弄清楚如何确保发送电子邮件。我目前正在使用 Mocha,但如果它能让这项任务更容易,我愿意切换到另一个测试框架。

您可以像这样使用夹具并覆盖电子邮件发送功能:

Email.send = function (options) {
   // store those somewhere like an emailsCollection
   emailsCollection.insert(options);
}; 

现在您可以在测试中对 emailsCollection 断言