Skip to content

CodeceptJS helper for simplest email check using remote maildev server

License

Notifications You must be signed in to change notification settings

kuzjka/codeceptjs-remote-maildev-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codeceptjs-remote-maildev-helper

CodeceptJS helper for simplest email check using remote maildev server

Installation

npm install --save-dev codeceptjs-remote-maildev-helper

Running remote server

On the target remote host clone codeceptjs-remote-maildev, install dependencies with npm and start. NodeJS should be installed.

git pull https://github.com/kuzjka/codeceptjs-remote-maildev.git
cd codeceptjs-remote-maildev
npm install
npm run serve

Alternatively, you can use Docker image

docker run --name remote-maildev -d kuzjka/codeceptjs-remote-maildev

By default, SMTP listens on port 25 and REST API is exposed on 8080. You can override it with SMTP_PORT and WEB_PORT environment variables.

CodeceptJS configuration

In codecept.conf.json:

{
  //...
  "helpers": {
    //...
    "RemoteMaildevHelper": {
      "require": "./node_modules/codeceptjs-remote-maildev-helper",
      "host": "123.124.125.126",
      "port": "8080"    
    }
  }
}

Default value for host is localhost, and for port is 8080.

You may run

npx codeceptjs def .

to generate typescript definitions for all installed helpers - this adds code autocompletion to IDEs, which support TypeScript.

Usage

Configure your application to use remote Maildev server (see Maildev docs).

In your CodeceptJS scenario use I.haveMailbox(address) to initialize mailbox and I.grabNextUnreadMail() to get email object.

For example:

Scenario('test email sending' async (I) => {
  I.haveMailbox('[email protected]');

  I.amOnPage('/sendMeEmail');
  I.fillField('email', '[email protected]');
  I.click('Send Me Email!');

  const email = await I.grabNextUnreadMail();

  I.say('I have email: ' + email.subject);
});

I.grabNextUnreadMail() returns Promise like all CodeceptJS grabber methods. It resolves to email object, which is used by Maildev and seems to conform Mailparser specification.

You may register more recipient addresses by adding more I.haveMailbox() calls.

License

MIT

About

CodeceptJS helper for simplest email check using remote maildev server

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •