Cypress generate random email2/29/2024 The test passes The Cypress test for the confirmation page The STMP server inside Cypressĭuring testing we want to receive the email the application is sending. Our Cypress test can be this: // cypress/integration/confirm-spec.jsĬy.get('#confirmation_code').type('wrongcode')Ĭy.get('').should('be.visible')Ĭy.get('').should('not.exist')Ĭy.get('#confirmation_code').clear().type('654agc') The confirmation page shows success message if the code is valid Confirmation page testĪs the first step, let's confirm the above page works - it should show an error message for an invalid code, and a success message for the valid one. The confirmation page can call the backend with the user-submitted code, or in my demo it simply verifies the input against the expected string "654agc". Html: 'Your confirmation code is 654agc',Ĭonsole.log('sent a confirmation email to %s', email) Text: 'Your confirmation code is 654agc', env file or environment variablesĬonst transporter = nodemailer.createTransport( = req.body create reusable transporter object using the default SMTP transport async.await is not allowed in global scope, must use a wrapper Here is an example script to send an email via a local SMTP server // send.js If you want to send an email from a Node program, I would suggest using the nodemailer module. Note: you can find the source code shown in this blog post at cypress-email-example and watch a video explaining the testing process here. We will test the HTML emails to make sure they look and work correctly. In this blog post, we will use a local SMTP server to receive emails sent by the app to the user.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |