-
-
Save jonstorer/11268262 to your computer and use it in GitHub Desktop.
# Given the following tests | |
Given I create an invitation for "[email protected]" | |
And I create an invitation for "[email protected]" | |
When I send my invitations | |
Then I should have sent emails to: | |
| email | | |
| [email protected] | | |
| [email protected] | | |
# If triggering the sending of the emails is synchronous, but sending the emails is asynchronous | |
# what is the appropriate level of testing for this feature? |
This entire flow is tested in Unit tests,
User saved, event emitted - done
Event emitted, function called - done
function called, emails sent - done
The question is, from an integration test, where we have a system that diverts processes to a new thread (desired flow).
Should we add a wait? - easy, but prone to race conditions
Break the test up into smaller pieces? - When we get as small as we need to, to be able to know when processes has completed, we will have duplicated the spec test.
Add an eventually
step which gives an assert n seconds to be true?
Well it's written in coffeescript
not node, but you get that.
I agree with @alexkehayias, send()
should return a promise in this case. The API should support this after all - what if the SMTP server is down?
Here's the small example written in node (our use case)