Friday, 1 April 2016

How do you test whether the right emails were sent from backend code?

Let's say you have an Express app with a /register path that is associated with a register(req, res, next) controller function, and it sends an email at the end of the registration saying 'Thanks for registering'. How can your integration tests (using Supertest) ensure that the mail contained the expected content?I'm interested in any solutions although currently I'm looking at using http://ift.tt/1Rx6LDy. It has a stub transport that it says is used for testing mail sending (http://ift.tt/1Y3Punm). But I can only see how to access the contents of the sent mail from within the controller function, but not from the test function (not cleanly, anyway).Are any of you testing your mail sending code and could explain how you are doing so? Or know of any code examples where this is being shown?

Submitted April 01, 2016 at 02:08PM by nowboarding

No comments:

Post a Comment