Last active
August 11, 2022 10:48
-
-
Save filiphric/e92d064df5cff422b4331dbb2741d402 to your computer and use it in GitHub Desktop.
Cypress request to mailosaur API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const userEmail = 'email.abcdefg@mailosaur.io' | |
| describe('Reset password flow', () => { | |
| it('Should receive an email and use reset password link', () => { | |
| // trigger reset password for user | |
| // this command is equal to clicking „I forgot my password“ link and entering user email | |
| cy | |
| .userPasswordReset(userEmail) | |
| cy | |
| .request({ | |
| method: 'POST', | |
| url: 'https://mailosaur.com/api/messages/await?server=abcdefg', // abcdefg is server name | |
| headers: { | |
| authorization: Cypress.env('mailosaurAuth') | |
| }, | |
| body: { | |
| 'sentTo': userEmail, | |
| 'subject': 'Password reset' | |
| } | |
| }).then( response => { | |
| // continue with test, open link | |
| cy | |
| .visit(response.body.text.links[1]) | |
| // fill in and confirm new password | |
| cy | |
| .get('#password') | |
| .type(newPassword); | |
| cy | |
| .get('#passwordConfirm') | |
| .type(newPassword); | |
| cy | |
| .get('#reset-change-password-btn') | |
| .should('be.visible') | |
| .should('be.enabled') | |
| .click(); | |
| // land on desired page after confirming password reset | |
| cy | |
| .location('href') | |
| .should('contains', '/login'); | |
| // login with my new password | |
| // ... | |
| }) | |
| }); | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey Irana, I’m pretty sure this way of checking the emails is deprecated. I suggest you take a look at the official mailosaur plugin: https://mailosaur.com/docs/frameworks-and-tools/cypress/