-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add unit tests for Nodemailer #184
Conversation
56dcce2
to
1f2582d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
38d2e22
to
7481522
Compare
7481522
to
fbb6a57
Compare
7818a61
to
9b202bf
Compare
5abb3a6
to
8a5d8df
Compare
8a5d8df
to
73689fd
Compare
73689fd
to
116d4f2
Compare
Please stop force pushing.... |
I think we don't need to squash and merge locally in general. It makes it hard to re-review changes. |
Exactly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
* Add unit tests for nodemailer * Make adjustments to Nodemailer module to work wiht Unit Tests * Add Nodemailer env vars to CI * Add nodemailer env vars to docker compose * Add env vars in right place in CI * Remove nodemailer env vars * Add dotenv to test script * Remove dotenv import * return a promise with resolve/reject * Use objectContaining/arrayContaining to read response * Add mailhog under services * Remove nested Promise * Use objectContaining/arrayContaining in all notification tests * Remove test log message * Remove await and extra catch * Add await and remove catch * Eliminate test dependency * Remove types where they are already inferred * Test against the whole item array * Assign value to messageId inside if block to prevent typecheck fail * remove exclamation mark after messageId * remove if block * use invariant to throw if sentMailResponse.messageId is undefined * Add blank lines for better readibility * Pass responseToJSON.items directly to expect * Add cross-env to test script * Remove invariant
788a2f2
to
2539126
Compare
const text = 'Sample text'; | ||
|
||
test('sending and receiving email notification using sendNotification()', async () => { | ||
const sentMailResponse = await sendNotification(recipient, subject, text); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one question. Is this response always same when provided email does not exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, even if the recipient is [email protected]
the email would still get delivered using MailHog. We don't need real email addresses for testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I was thinking we might need a fail case testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In production, we would expect it to fail. Here, we are just testing if are able to send/receive notifications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhhh there is a distinction between production testing and dev testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I was thinking we might need a fail case testing.
I could add that in a follow-up.
* Add unit tests for nodemailer * Make adjustments to Nodemailer module to work wiht Unit Tests * Add Nodemailer env vars to CI * Add nodemailer env vars to docker compose * Add env vars in right place in CI * Remove nodemailer env vars * Add dotenv to test script * Remove dotenv import * return a promise with resolve/reject * Use objectContaining/arrayContaining to read response * Add mailhog under services * Remove nested Promise * Use objectContaining/arrayContaining in all notification tests * Remove test log message * Remove await and extra catch * Add await and remove catch * Eliminate test dependency * Remove types where they are already inferred * Test against the whole item array * Assign value to messageId inside if block to prevent typecheck fail * remove exclamation mark after messageId * remove if block * use invariant to throw if sentMailResponse.messageId is undefined * Add blank lines for better readibility * Pass responseToJSON.items directly to expect * Add cross-env to test script * Remove invariant
Description
Resolves #147 by adding initial Unit Tests to test the functionality of Nodemailer. I had to adjust the
sendNotification
function for unit testing. Also, I have modified thetests
script to requiredotenv/config
to read environment variables defined in.env.example
.Steps to Test
npm test
(all tests should pass)