admin管理员组文章数量:1289879
An email is being sent in my case ( 1. When resetting the password, 2. Adding a New member) during both API and UI tests. How can I access these emails without actually logging into my mail manual and accessing the content, so I can add them to the test and verify?
The test is something like the below.
- User can reset the password.
- Mail is triggered.
- User uses the link in the mail to reset the password.
- User logs in again using the new password.
Second test.
- Admin adds a member.
- Admin adds a new member and gets a mail about confirmation.
- verify the mail sent to the new member's email.
Would appreciate any help here.
I have tried to look into the third parties but it seems I need to use their email accounts I was hoping if someone can help me regarding Gmail(accessing the content of emails going to Gmail)
An email is being sent in my case ( 1. When resetting the password, 2. Adding a New member) during both API and UI tests. How can I access these emails without actually logging into my mail manual and accessing the content, so I can add them to the test and verify?
The test is something like the below.
- User can reset the password.
- Mail is triggered.
- User uses the link in the mail to reset the password.
- User logs in again using the new password.
Second test.
- Admin adds a member.
- Admin adds a new member and gets a mail about confirmation.
- verify the mail sent to the new member's email.
Would appreciate any help here.
I have tried to look into the third parties but it seems I need to use their email accounts I was hoping if someone can help me regarding Gmail(accessing the content of emails going to Gmail)
Share Improve this question edited Aug 18, 2022 at 7:56 Sadeed_pv 5652 gold badges11 silver badges24 bronze badges asked Jul 27, 2022 at 11:09 ruffainnruffainn 1011 silver badge15 bronze badges 3- There are a few 3rd party plugins that can allow Cypress to work with emails. docs.cypress.io/plugins/directory#Email – jjhelguero Commented Jul 27, 2022 at 15:42
- Thanks but it seems most of them are paid, I was hoping if there is some other ways to do it or a free third party? – ruffainn Commented Jul 29, 2022 at 19:59
- 1 Find an email server that dumps emails to folders/files (e.g., smtp-dump and have your tests look for/read the files there. – Heretic Monkey Commented Jul 29, 2022 at 23:45
4 Answers
Reset to default 6
- If your application is running locally and is sending the emails directly through an SMTP server, you can use a temporary local test SMTP server running inside Cypress. Read the blog post "Testing HTML Emails using Cypress" for details.
- If your application is using a 3rd party email service, or you cannot stub the SMTP requests, you can use a test email inbox with an API access. Read the blog post "Full Testing of HTML Emails using SendGrid and Ethereal Accounts" for details.
Taken from the official best practice page at "Verifying sent emails". Read more here.
If you are looking for a free third-party email client (of course with just 100 emails per month) you can use testmail.app
This app is pretty much basic and easy to integrate with cypress
.
You can find docs here
To check if an email have been correctly sent by your application in a Cypress E2E test, you can use an external service like TestSendr.
This (free) service will allow you to send an email to something ending by @testsendr.link, and then check the email received via a simple REST API. Check the quick start!
There are various 3rd party solutions that provide real email addresses you can access via an API. These e with plugins for Cypress that can help you with exactly this scenario. See here: https://docs.cypress.io/plugins#email
Some also offer SMTP servers which is useful in staging or dev environments so all email gets captured in them and you don't send external emails.
Our pany uses Mailosaur to test both of the scenarios you mention, password reset and email validation during account creation but of course you can use others mentioned here too.
本文标签: javascriptHow can I acess content of email triggered by a test in CypressStack Overflow
版权声明:本文标题:javascript - How can I acess content of email triggered by a test in Cypress - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741445053a2379146.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论