When testing end to end integration testing using TestCafe how to manage waiting for email receipt

Viewed 146

With system under test, when adding a new user their initial password is emailed to them.

I could split my test into multiple sections with manual intervention but this is less than ideal.

Appreciate any suggestions on how to proceed using TestCafe as I am sure others have encountered this as well.

1 Answers

If you run full integration test with real email server, then you can use libraries like "mail-receive" to connect to this server and verify the email.

You can also run your backend/server logic in mock mode, and then verify the mock, that the send event happened, by calling some test-specific rest endpoint from your TestCafe test.

Alternatively, you could also use something like "smtp-receiver" to start your own email-server-mock in nodejs context, and receive event upon email arrival. However you will need to configure your app server/backend to point to this mocked email server.

Related