Skip to content

kuzjka/codeceptjs-maildev-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codeceptjs-maildev-helper

Maildev integration for CodeceptJS.

Installation

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

Configuration

in codecept.json:

  ...
  "helpers": {
    ...
    "MaildevHelper": {
      "require": "./node_modules/codeceptjs-maildev-helper"
      "port": 12325
    }
  },
  ...

port is optional. Default value is 1025.

You may run

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 local 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 recepient addresses by adding more I.haveMailbox() calls.

License

MIT

About

Maildev integration for CodeceptJS

Resources

License

Stars

Watchers

Forks

Packages

No packages published