-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return a mocked status when sending emails in test/preview mode. #473
Comments
Heya, sorry for slowness on the response. Deprioritized when I saw your workaround then forgot 🙃 I believe this is the block returning undefined: mailing/packages/core/src/index.ts Lines 151 to 160 in cea4bdb
Your workaround seems good if that works for you. The difficulty with this feature would be that different transports will have different response types. I'm open to just making a generic response (e.g. I'd opt to close if the workaround is good enough but lmk. |
I think returning an empty object is a good start. I am confused about how standard a "transport" is, and whether or not they all return the SMTP stats codes, etc. But, again, with this workaround, a bit of documentation, and returning an empty object that's probably enough. |
Found the doc on transport return types here: https://nodemailer.com/plugins/create/#transports Looks like the common return type includes
I'd be open to just use that as a spec for a dummy return value. Of course, there are no promises that 3rd party nodemailer transports (e.g. the mailgun one) conform to this. |
That's perfect, exactly what I was hoping. Nice find. |
Is your feature request related to a problem? Please describe.
I'm wanting to check that an email was successfully sent (or not) before deleting an item from our notification queue.
In prod/regular sending mode, it returns the .json() of the underlying nodemailer result on line 68:
mailing/packages/cli/src/pages/api/sendMail.ts
Lines 60 to 76 in cea4bdb
Unfortunately, in test/preview mode, the sendMail function doesn't return anything. Maybe this was a simple oversight? Could it be as simple as just adding a
return
in front of lines 46 and 50?mailing/packages/cli/src/pages/api/previews/send.ts
Lines 40 to 53 in cea4bdb
Or maybe I'm confused and these are actually the relevant lines:
mailing/packages/cli/src/preview/controllers/intercepts.tsx
Lines 19 to 32 in cea4bdb
UPDATE:
I just tried, on a hunch, some .then/.catch syntax and it works:
logs "RESOLVED" when testing (even with no
to:
email address) and "FAILED" if I don't provide acomponent
prop.Maybe that's GEFN?
Describe the solution you'd like
I think returning a mocked status that closely resembles what nodemailer would give, i.e. a successful promise with perhaps an auto-generated message ID, 200 status code, etc., would be best.
The text was updated successfully, but these errors were encountered: