Gathering detailed insights and metrics for cypress-mailosaur
Gathering detailed insights and metrics for cypress-mailosaur
Gathering detailed insights and metrics for cypress-mailosaur
Gathering detailed insights and metrics for cypress-mailosaur
Mailosaur email and SMS testing commands for Cypress
npm install cypress-mailosaur
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
82 Stars
110 Commits
9 Forks
2 Watching
1 Branches
7 Contributors
Updated on 11 Nov 2024
JavaScript (97.66%)
CSS (1.25%)
HTML (1.09%)
Cumulative downloads
Total Downloads
Last day
-16.8%
17,643
Compared to previous day
Last week
-9%
98,807
Compared to previous week
Last month
7.7%
437,442
Compared to previous month
Last year
33.6%
4,507,479
Compared to previous year
Using Cypress and Mailosaur together you can:
Mailosaur is a service that lets you automate email testing (e.g. email verification, password resets, etc.) and SMS testing (e.g. one-time passwords).
Mailosaur also provides dummy SMTP servers to test with; allowing you to catch email in staging environments - preventing email being sent to customers by mistake.
Follow these steps to start testing email with Cypress:
Install the Mailosaur commands via npm
or yarn
:
1npm i -D cypress-mailosaur 2# or 3yarn add -D cypress-mailosaur
Once downloaded, add the following line to cypress/support/e2e.js
(or cypress/support/index.js
in older versions of Cypress) to import the commands into your Cypress project:
1require('cypress-mailosaur');
Mailosaur commands need your Mailosaur API key to work. You can learn about managing API keys here.
cypress.config.js
1module.exports = defineConfig({ 2 env: { 3 MAILOSAUR_API_KEY: "your-key-here", 4 }, 5 6 // ... 7}); 8
To set the environment variable on your machine, it needs to be prefixed with either CYPRESS_
or cypress_
.
1export CYPRESS_MAILOSAUR_API_KEY=your-key-here
For this example, we'll navigate to a password reset page, request a new password link (sent via email), and get that email.
Create a new test spec:
1touch cypress/e2e/password-reset.cy.js
Now edit the file to something like this:
1describe('Password reset', () => { 2 const serverId = 'abcd1234' 3 const serverDomain = 'abcd1234.mailosaur.net' 4 const emailAddress = 'password-reset@' + serverDomain 5 6 it('Makes a Password Reset request', () => { 7 cy.visit('https://github.com/password_reset') 8 cy.title().should('equal', 'Forgot your password?') 9 cy.get('#email_field').type(emailAddress) 10 }) 11 12 it('Gets Password Reset email from Mailosaur', () => { 13 cy.mailosaurGetMessage(serverId, { 14 sentTo: emailAddress 15 }).then(email => { 16 expect(email.subject).to.equal('Reset your password'); 17 passwordResetLink = email.text.links[0].href; 18 }) 19 }) 20 21 it('Follows the link from the email', () => { 22 const validPassword = 'delighted cheese jolly cloud' 23 24 cy.visit(passwordResetLink) 25 cy.title().should('contain', 'Change your password') 26 cy.get('#password').type(validPassword) 27 cy.get('#password_confirmation').type(validPassword) 28 cy.get('form').submit() 29 }) 30})
You can test pretty much anything with Mailosaur and Cypress, including:
For more information, check out the full Mailosaur docs for the most up-to-date guides and troubleshooting tips.
Mailosaur Team, Premium, and Ultimate customers can perform SMS tests with Cypress, whilst Trial account users can just ask support to enable this feature to try it out!
SMS testing works in just the same way as email testing above. However rather than dealing with email addresses, you search using phone numbers instead. For example:
1cy.mailosaurGetMessage(serverId, { 2 sentTo: '447555111222' 3}).then(sms => { 4 expect(sms.text.body).to.equal('Your OTP code is: 123456') 5})
Install all development dependencies:
1cd test/react-app 2npm i 3cd ../../ 4npm i
The test suite requires the following environment variables to be set:
1export CYPRESS_MAILOSAUR_API_KEY=your_api_key 2export CYPRESS_MAILOSAUR_SERVER=server_id
Run all tests:
1npm test
You can get us at support@mailosaur.com
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 1
Details
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
34 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More