Cypress JS testing guide (automated testing tutorial)
Example Cypress.js tutorial for automated testing with fake email accounts. Test user sign up with browser automation in NodeJS.
See the CypressJS testing guide for in-depth tutorial.
Testing with CypressJS
Cypress is a powerful test automation tool that can be used to test applications end-to-end. By enabling the MailSlurp plugin you can send and receive emails and SMS messages during tests to verify OTP passcodes, password reset flows, and user sign-up.
Use cases for Cypress
Using automated testing is a great way to validate processes and ensure the stability of software. Many developers and QA test teams use tools like Cypress, Playwright, Selenium and Robot to detect regressions and bugs.
Is it the same as Selenium?
Cypress is built around a bundled electron browser and differs to Selenium. It can be installed using NPM and launch a browser without dependencies. Cypress can still be used to control other browsers including Edge and Firefox.
What can Cypress do?
Automated test tools like Cypress can be used to test websites and apps end-to-end using device emulation. You can also test React or Vue components in frameworks like Next JS by rending views to a browser dom.
Testing email processes
Cypress can also test email sending and receiving. By adding MailSlurp to your Cypress tests you can easily send and receive emails in tests. See the example project for more.
CypressJS SMS testing
MailSlurp can also be used with CypressJs to receive SMS text messages to real phone numbers that you create. See the SMS testing guide or the documentation for more information.
Getting started with cypress
To get started install NodeJS and use npm to add the package:
npm install cypress --save-dev
You can then write test files in a familiar Javascript way:
it('can load oauth demo site', () => {
cy.visit('https://playground.mailslurp.com');
cy.contains('Sign in to your account');
});
Related links
Take your tests a step further with these guides and tutorials: