Table of Contents
Intro
Codecept Helper with that consumes the temp-mail.ru api for test scenarios that require email interaction. An example scenario can be found below
Config
Add to codecept.conf.js
with:
exportsconfig = helpers: Nightmare: url: "http://localhost" Mailbox: "require": "node_modules/codeceptjs-tempmail" /*...some config*/
or to codecept.json
with:
Mailbox
Extends Helper
Helper with disposable mailbox api that is availible within test execution.
Parameters
config
constructor
Parameters
config
Object configuration can be overridded by values found incodecept.json
createMailbox
Parameters
name
string? Optional string to be used in mainlbox address
Examples
I //{address: "testmail@doanart.com", messages: {error: "there are no messages yet"}}I //{address: "taij1q1j8n8@doanart.com", messages: {error: "there are no messages yet"}}
Returns object Creates a mailbox object and checks for mail before returning.
deleteLatestMessage
Parameters
mailbox
object? Takes a mailbox object and detletes the last (i.e. most recent) value from messages and the mail server. (optional, defaultthis.mailbox
)
getMailbox
Parameters
debug
boolean Logs the mailbox out to the console to aid debugging. (optional, defaultfalse
)
Returns any The mailbox object in it's current state, i.e. if you have called the methods elsewhere in this file without arguments, the Mailbox object is updated internally. This returns it.
getMailbox
Returns any The mailbox object in it's current state, i.e. if you have called the methods elsewhere in this file without arguments, the Mailbox object is updated internally. This returns it.
getLatestMessage
Parameters
mailbox
any {object=} mailbox - Takes a mailbox object and assigns amailbox.latest
object with the last (i.e. most recent) value in the messages array returned from the server. (optional, defaultthis.mailbox
)
getMailById
Parameters
id
string Takes a mail_id string and returns it from themailbox.messages
array
waitForMessage
Parameters
mailbox
object? Takes a mailbox object and makes 10 attempts at retrieving messages from the server. Once a suitible response is recieved themailbox.messages
andmailbox.latest
are updated. (optional, defaultthis.mailbox
)
Example
; ; ; ; ;