Giter Site home page Giter Site logo

buob / cypress-mailosaur Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mailosaur/cypress-mailosaur

0.0 1.0 0.0 352 KB

Mailosaur Cypress Commands

Home Page: https://mailosaur.com

License: MIT License

JavaScript 95.91% HTML 1.90% CSS 2.18%

cypress-mailosaur's Introduction

Mailosaur Cypress Commands

This package provides Cypress commands to help you test email and SMS as part of end-to-end testing with Mailosaur.

Install and configure

1. Install via npm

npm install cypress-mailosaur --save-dev

2. Include the commands

Add the following line to cypress/support/index.js:

import 'cypress-mailosaur'

3. Authenticate

Mailosaur commands need your Mailosaur API key to work. You can get your key via the account settings screen.

Option 1: Add API key to cypress.json

{  
  "env": {
    "MAILOSAUR_API_KEY": "your-key-here"
  }
}

Option 2: Add API key to a cypress.env.json file

You can create your own cypress.env.json file that Cypress will automatically check. This is useful because if you add cypress.env.json to your .gitignore file, the values in here can be different for each developer machine.

{  
  "MAILOSAUR_API_KEY": "your-key-here"
}

Option 3: Set API key via a system environment variable

To set the environment variable on your machine, it needs to be prefixed with either CYPRESS_ or cypress_.

export CYPRESS_MAILOSAUR_API_KEY=your-key-here

Example usage

context('Account activation', () => {
  it('should send an activation email', () => {
    cy.mailosaurGetMessage('SERVER_ID', { subject: 'Activate your account' })
      .then(email => {
        expect(email.subject).to.equal('Activate your account');
      })
      .then(email => {
        expect(email.attachments).to.have.lengthOf(0);
      })
      .then(email => {
        const $body = Cypress.$(email.html.body)
        const buttonText = $body.find('.button.button--green').text();

        expect(buttonText).to.equal('Activate now')
      })
  })
})

Check out the full documentation here.

Commands

mailosaurListServers()
mailosaurCreateServer({ name })
mailosaurGetServer(serverId)
mailosaurUpdateServer(serverId, server)
mailosaurDeleteServer(serverId)
mailosaurGenerateEmailAddress(serverId)
mailosaurListMessages(serverId)
mailosaurCreateMessage(serverId)
mailosaurGetMessage(serverId, criteria)
mailosaurGetMessageById(messageId)
mailosaurSearchMessages(serverId, criteria, options)
mailosaurGetMessagesBySubject(serverId, subjectSearchText)
mailosaurGetMessagesByBody(serverId, bodySearchText)
mailosaurGetMessagesBySentTo(serverId, emailAddress)
mailosaurDeleteMessage(messageId)
mailosaurDeleteAllMessages(serverId)
mailosaurDownloadAttachment(attachmentId)
mailosaurDownloadMessage(messageId)
mailosaurGetSpamAnalysis(messageId)

Note on parameters

  • serverId - Found on the servers list within Mailosaur.
  • server - A valid server object.
  • critera - An object containing either { sentTo: '[email protected]' }, { subject: 'Something' } or { body: 'Activate your account' }.

cypress-mailosaur's People

Contributors

jm-mailosaur avatar lesliecdubs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.