All Projects → Clebiez → cypress-maildev

Clebiez / cypress-maildev

Licence: MIT license
Cypress Maildev is a bunch of Cypress commands in order to test your messages (SMS and Emails) by using Maildev REST API.

Programming Languages

javascript
184084 projects - #8 most used programming language
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to cypress-maildev

angular-cli-skeleton
angular-cli skeleton to quickly start a new project with advanced features and best practices. All features are described in README.md.
Stars: ✭ 32 (+68.42%)
Mutual labels:  test, e2e
alexa-skill-clean-code-template
Alexa Skill Template with clean code (eslint, sonar), testing (unit tests, e2e), multi-language, Alexa Presentation Language (APL) and In-Skill Purchases (ISP) support. Updated to ASK-CLI V2.
Stars: ✭ 34 (+78.95%)
Mutual labels:  test, e2e
cypress-test-tiny
Tiny Cypress E2E test case
Stars: ✭ 48 (+152.63%)
Mutual labels:  test, cypress
jest-retry
Jest retry pattern for flaky E2E tests
Stars: ✭ 36 (+89.47%)
Mutual labels:  test, e2e
Testcafe
A Node.js tool to automate end-to-end web testing.
Stars: ✭ 9,176 (+48194.74%)
Mutual labels:  test, e2e
babel-plugin-remove-test-ids
🐠 Babel plugin to strip `data-test-id` HTML attributes
Stars: ✭ 40 (+110.53%)
Mutual labels:  e2e, cypress
skywalking-infra-e2e
Apache SkyWalking Infra E2E
Stars: ✭ 30 (+57.89%)
Mutual labels:  test, e2e
odoo-cypress
Odoo Framework E2E Testing using Cypress
Stars: ✭ 19 (+0%)
Mutual labels:  e2e, cypress
Tib
Easy e2e browser testing in Node
Stars: ✭ 64 (+236.84%)
Mutual labels:  test, e2e
Cypress
Fast, easy and reliable testing for anything that runs in a browser.
Stars: ✭ 35,145 (+184873.68%)
Mutual labels:  test, cypress
cypress-xhr-responses-recording
No description or website provided.
Stars: ✭ 19 (+0%)
Mutual labels:  e2e, cypress
Javascript Testing Best Practices
📗🌐 🚢 Comprehensive and exhaustive JavaScript & Node.js testing best practices (August 2021)
Stars: ✭ 13,976 (+73457.89%)
Mutual labels:  test, e2e
cypress-browser-permissions
A Cypress plugin to set launched browser preferences including permissions like Geolocation, Notifications, Microphone, etc.
Stars: ✭ 40 (+110.53%)
Mutual labels:  e2e, cypress
very good performance
Utility on top of the Flutter Driver API that facilitates measuring the performance of your app in an automated way created by Very Good Ventures 🦄
Stars: ✭ 78 (+310.53%)
Mutual labels:  test, e2e
Recorder
A browser extension that generates Cypress, Playwright and Puppeteer test scripts from your interactions 🖱 ⌨
Stars: ✭ 277 (+1357.89%)
Mutual labels:  e2e, cypress
cypress-angularjs-unit-test
Unit test Angularjs code using Cypress.io test runner
Stars: ✭ 23 (+21.05%)
Mutual labels:  test, cypress
cypress-page-object
Represent the screens of your website as a series of objects in your Cypress test suite
Stars: ✭ 23 (+21.05%)
Mutual labels:  e2e, cypress
angular-webpack-skeleton
This project is deprecated. Please refer to https://github.com/Ks89/angular-cli-skeleton
Stars: ✭ 16 (-15.79%)
Mutual labels:  test, e2e
Cypress Svelte Unit Test
Unit testing Svelte components in Cypress E2E test runner
Stars: ✭ 110 (+478.95%)
Mutual labels:  test, e2e
cygger
Boilerplate generator for API Testing from Swagger to Cypress
Stars: ✭ 20 (+5.26%)
Mutual labels:  e2e, cypress

Cypress Maildev

Cypress Maildev is a bunch of Cypress commands in order to test your messages (SMS and Emails) by using Maildev REST API.

CI npm version

Installation

npm install cypress-maildev --save-dev
yarn add cypress-maildev --dev

Usage

1. Register the plugin :

// cypress/support/e2e.js

require('cypress-maildev');

2. Specify your maildev address

By default, Maildev API is started at the http://localhost:1080. If you are using default maildev instance, you have nothing to do!

You can also use env vars in your cypress.config.js as below :

const { defineConfig } = require("cypress");

module.exports = defineConfig({
  env: {
    MAILDEV_PROTOCOL: "http",
    MAILDEV_HOST: "localhost",
    MAILDEV_SMTP_PORT: "1025",
    MAILDEV_API_PORT: "1080",
  },
});

For example, by using like this project a docker compose with cypress and maildev containers, you have to configure your cypress.config.js like this:

const { defineConfig } = require("cypress");

module.exports = defineConfig({
  env: {
    MAILDEV_PROTOCOL: "http",
    MAILDEV_HOST: "localhost",
    MAILDEV_SMTP_PORT: "1025",
    MAILDEV_API_PORT: "1080",
  },
});

Check the Maildev REST API documentation for what you can expect in responses.

Commands

Usage

All of theses commands use directly cy.request() which return a Cypress Promise like. Check the doc !

Using one of this commands must be like this example :

  cy.maildevGetLastMessage().then((email) => {
    expect(email.subject).to.equal("I'm the last email sent !");
  });

For more examples you can check directly the test file.

Documentation

Get all messages received in the Maildev instance.

cy.maildevGetAllMessages()

Get the last message received.

cy.maildevGetLastMessage()

Each messages got an internal ID. If you know it, you can find it directly.

cy.maildevGetMessageById(id: String)

You can also directly access to the HTML of your email by calling.

cy.maildevVisitMessageById(id: String)

And you can use Cypress promise to manipulate or assert the DOM of your email :

  cy.maildevVisitMessageById(id: String);
  cy.get('body h1').should('have.text', 'Email incoming !');
  cy.get('body a').should('exist').and('have.text', 'click on this link');

You must have to specify "chromeWebSecurity": false, because you will access to another domain than your app. Unfortunately, Cypress can't deactivate the cross-origin requests for Firefox actually.


Get all messages and find one by containing a specific subject. It's a simple string detection case-sensitive.

cy.maildevGetMessageBySubject(subject: String)

Get all messages and find the last containing a sent to address. Use a strict string comparison.

cy.maildevGetMessageBySentTo()

Delete a message by giving the ID. In can be useful if you to only keep message that you haven't read yet.

cy.maildevDeleteMessageById()

Delete all message in order to flush your mailbox !

cy.maildevDeleteAllMessages()

Get an OTP code from a string. It can be used outside of maildev box because it doesn't use maildev API but generally OTP code are sent by messages. This function find in a string a specific amount of digits (default 6).

cy.maildevGetOTPCode(string, digits = 6)

Or use with another maildev command

  cy.maildevGetMessageBySubject("Your code").then(message => {
    cy.maildevGetOTPCode(message.text).then(code => {
      // Do something with the code
    });
  });

Simple test command that return true if Maildev is opened.

cy.maildevHealthcheck()

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

  • Clone the repo

  • Install dependencies: make install

  • Start maildev: make start

Please make sure to update tests as appropriate and run make test command

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].