{"id":24753874,"url":"https://github.com/codeceptjs/mailslurp-helper","last_synced_at":"2025-08-01T03:39:28.884Z","repository":{"id":42533070,"uuid":"204027831","full_name":"codeceptjs/mailslurp-helper","owner":"codeceptjs","description":"MailSlurp helper for testing emails","archived":false,"fork":false,"pushed_at":"2025-07-14T23:47:11.000Z","size":158,"stargazers_count":4,"open_issues_count":5,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-22T16:34:39.352Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeceptjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-08-23T15:46:18.000Z","updated_at":"2025-03-20T04:16:21.000Z","dependencies_parsed_at":"2024-11-06T13:26:09.880Z","dependency_job_id":"43580c87-20f9-411e-91f4-5eeacd64cfcc","html_url":"https://github.com/codeceptjs/mailslurp-helper","commit_stats":{"total_commits":60,"total_committers":12,"mean_commits":5.0,"dds":0.7,"last_synced_commit":"873e622bedc8d4d3d6335722339a0a8e3f61b187"},"previous_names":["codecept-js/mailslurp-helper"],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/codeceptjs/mailslurp-helper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeceptjs%2Fmailslurp-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeceptjs%2Fmailslurp-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeceptjs%2Fmailslurp-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeceptjs%2Fmailslurp-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeceptjs","download_url":"https://codeload.github.com/codeceptjs/mailslurp-helper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeceptjs%2Fmailslurp-helper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268057147,"owners_count":24188616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-28T11:36:38.689Z","updated_at":"2025-08-01T03:39:28.856Z","avatar_url":"https://github.com/codeceptjs.png","language":"TypeScript","readme":"# MailSlurp helper for CodeceptJS\n\nMailSlurp helper for testing emails with [MailSlurp service](https://mailslurp.com).\nMailSlurp creates disposable mailbox for each test and removes it after a test.\n\n## Setup\n\nRegister and obtain API key from [MailSlurp](https://mailslurp.com).\n\n    npm i @codeceptjs/mailslurp-helper --save\n\nEnable helper in `codecept.conf.js`.\n\n```js\nhelpers: {\n  MailSlurp: {\n    apiKey: '\u003cinsert api key here\u003e',\n    require: '@codeceptjs/mailslurp-helper'    \n  },\n}\n```\n\n## Use Cases\n\nUse this helper in your tests to check email interactions. The most popular one\n\n-   Account activation\n-   Restore forgotten password\n-   Action verification\n\n## Use Case: Restore Password\n\n```js\nconst mailbox = await I.haveNewMailbox();\n// wait 10 seconds for an email\nconst email = await I.waitForLatestEmail(10);\nI.seeInEmailSubject('Restore Password');\nI.seeInEmailBody('Click link to restore password');\nconst restoreUrl = email.body.match(/http(s):\\/\\/(.*?)\\s/)[0];\nI.amOnPage(restoreUrl);\n```\n\n## Switching Between Mailboxes\n\n```js\nconst mailbox1 = await I.haveNewMailbox();\nconst mailbox2 = await I.haveNewMailbox();\nI.openMailbox(mailbox1);\nconst email = I.waitForEmailMatching({ subject: 'Register' });\n```\n\n## Using Custom Assertions In Tests\n\n```js\nconst assert = require('assert');\nconst mailbox = await I.haveNewMailbox();\nconst email = await I.waitForEmailMatching({ subject: 'Thanks' });\nassert.eql(email.subject, 'Thanks for registering')\n```\n\n## LICENSE\n\nMIT\n\n## API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n#### Table of Contents\n\n-   [Configuration](#configuration)\n-   [Configuration](#configuration-1)\n    -   [Properties](#properties)\n-   [haveNewMailbox](#havenewmailbox)\n-   [haveExistingMailbox](#haveexistingmailbox)\n    -   [Parameters](#parameters)\n-   [openMailbox](#openmailbox)\n    -   [Parameters](#parameters-1)\n-   [sendEmail](#sendemail)\n    -   [Parameters](#parameters-2)\n-   [waitForLatestEmail](#waitforlatestemail)\n    -   [Parameters](#parameters-3)\n-   [waitForEmailMatching](#waitforemailmatching)\n    -   [Parameters](#parameters-4)\n-   [waitForNthEmail](#waitfornthemail)\n    -   [Parameters](#parameters-5)\n-   [grabEmailsMatching](#grabemailsmatching)\n    -   [Parameters](#parameters-6)\n-   [grabAllEmailsFromMailbox](#graballemailsfrommailbox)\n-   [seeInEmailSubject](#seeinemailsubject)\n    -   [Parameters](#parameters-7)\n-   [dontSeeInEmailSubject](#dontseeinemailsubject)\n    -   [Parameters](#parameters-8)\n-   [seeInEmailBody](#seeinemailbody)\n    -   [Parameters](#parameters-9)\n-   [dontSeeInEmailBody](#dontseeinemailbody)\n    -   [Parameters](#parameters-10)\n-   [seeEmailIsFrom](#seeemailisfrom)\n    -   [Parameters](#parameters-11)\n-   [seeEmailSubjectEquals](#seeemailsubjectequals)\n    -   [Parameters](#parameters-12)\n-   [dontSeeEmailSubjectEquals](#dontseeemailsubjectequals)\n    -   [Parameters](#parameters-13)\n-   [seeNumberOfEmailAttachments](#seenumberofemailattachments)\n    -   [Parameters](#parameters-14)\n-   [seeEmailAttachment](#seeemailattachment)\n    -   [Parameters](#parameters-15)\n\n### Configuration\n\nAllows to use real emails in E2E tests via [MailSlurp service](https://mailslurp.com).\nSign up for an account at MailSlurp to start.\n\nA helper requires `apiKey` from MailSlurp to start\n\n```js\nhelpers: {\n  MailSlurp: {\n    apiKey: '\u003cinsert api key here\u003e',\n    require: '@codeceptjs/mailslurp-helper'\n  },\n}\n```\n\n\u003e Use .env file and environment variables to store sensitive data like API keys\n\n### Configuration\n\n-   `apiKey` (required) -  api key from MailSlurp\n-   `timeout` (default: 10000) - time to wait for emails in milliseconds.\n-   `debug` (default: false) - print debug logs\n\nType: {apiKey: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), timeout: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?, debug: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?}\n\n#### Properties\n\n-   `apiKey` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n-   `timeout` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** \n-   `debug` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** \n\n### haveNewMailbox\n\nCreates a new mailbox. A mailbox will be deleted after a test.\nSwitches to last created mailbox.\n\n```js\nconst mailbox = await I.haveNewMailbox();\n```\n\n### haveExistingMailbox\n\nUse an existing mailbox.\n\n```js\nconst mailbox = await I.haveExistingMailbox('94cxxxf4-7231-46ce-9f40-xxxcae39xxxx');\n```\n\n#### Parameters\n\n-   `mailboxId` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** ID of an existing MailSlurp inbox.\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;Inbox\u003e** \n\n### openMailbox\n\nChange a current mailbox to a provided one:\n\n```js\nconst mailbox1 = await I.haveMailbox();\nconst mailbox2 = await I.haveMailbox();\n// mailbox2 is now default mailbox\n// switch back to mailbox1\nI.openMailbox(mailbox)\n```\n\n#### Parameters\n\n-   `mailbox`  \n\n### sendEmail\n\nSends an email from current mailbox, created by `I.haveNewMailbox()`.\n\n```js\nI.sendEmail({\n  to: ['user@site.com'],\n  subject: 'Hello',\n  body: 'World'\n});\n```\n\n#### Parameters\n\n-   `data`  \n\n### waitForLatestEmail\n\nWaits for the first email in mailbox.\nIf mailbox is not empty - opens the last email.\n\n```js\nI.waitForLatestEmail()\n// wait for 30 seconds for an email\nI.waitForLatestEmail(30);\n```\n\n#### Parameters\n\n-   `sec` **num?** Number of seconds to wait.\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;Email\u003e** an email received.\n\n### waitForEmailMatching\n\nWait for an exact email matched by query. You can match emails by `from`, `to`, `subject`, `cc`, `bcc` fields.\nMy default, non-strcit matching enabled, so it searches for inclusion of a string. For a strict matching (equality)\nprepend a value with `=` prefix.\n\n```js\n // wait for email with 'password' in subject\nconst email = await I.waitForEmailMatching({\n subject: 'password',\n});\n\n// wait 30 seconds for email with exact subject\nconst email = await I.waitForEmailMatching({\n subject: '=Forgot password',\n}, 30);\n\n//\nconst email = await I.waitForEmailMatching({\n from: '@mysite.com', // find anything from mysite\n subject: 'Restore password', // with Restore password in subject\n});\n```\n\n#### Parameters\n\n-   `query` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** to locate an email\n-   `sec` **num?** Number of seconds to wait.\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;Email\u003e** an email received.\n\n### waitForNthEmail\n\nWait for exact number of emails in mailbox. Returns the last email in the list.\n\n```js\n// wait for 2 emails\nI.waitForNthEmail(2);\n// wait for 5 emails for 60 seconds\nI.waitForNthEmail(5, 60);\n// wait for 2 emails and return the last one\nconst email = await I.waitForNthEmail(2);\n```\n\n#### Parameters\n\n-   `number`  \n-   `sec`  \n\n### grabEmailsMatching\n\nReturns a bunch of emails matched by query.\nSimilar to `waitForEmailMatching` but returns an array of emails.\n\n```js\n// return 2 emails from 'user@user.com'\nconst emails = await I.grabEmailsMatching({ from: 'user@user.com'}, 2);\n```\n\n#### Parameters\n\n-   `query` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** to locate an email\n-   `num` **num?** Number of emails to return.\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;\\[Email]\u003e** emails matching criteria.\n\n### grabAllEmailsFromMailbox\n\nReturns all emails from a mailbox.\n\n```js\nconst emails = await I.grabAllEmailsFromMailbox();\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;\\[Email]\u003e** emails.\n\n### seeInEmailSubject\n\nChecks that current email subject contains a text.\n\n```js\nI.seeInEmailSubject('Restore password');\n```\n\nRequires an opened email. Use either `waitForEmail*` methods to open. Or open manually with `I.openEmail()` method.\n\n#### Parameters\n\n-   `text`  \n\n### dontSeeInEmailSubject\n\nChecks that current email subject does not contain a text.\n\n```js\nI.seeInEmailSubject('Restore password');\n```\n\nRequires an opened email. Use either `waitForEmail*` methods to open. Or open manually with `I.openEmail()` method.\n\n#### Parameters\n\n-   `text`  \n\n### seeInEmailBody\n\nChecks that current email body contains a text.\n\n```js\nI.seeInEmailBody('Click link');\n```\n\nRequires an opened email. Use either `waitForEmail*` methods to open. Or open manually with `I.openEmail()` method.\n\n#### Parameters\n\n-   `text`  \n\n### dontSeeInEmailBody\n\nChecks that current email body does not contain a text.\n\n```js\nI.dontSeeInEmailBody('Click link');\n```\n\nRequires an opened email. Use either `waitForEmail*` methods to open. Or open manually with `I.openEmail()` method.\n\n#### Parameters\n\n-   `text`  \n\n### seeEmailIsFrom\n\nChecks that email is from a specified address.\n\n```js\nI.seeEmailIsFrom('user@user.com');\n```\n\nRequires an opened email. Use either `waitForEmail*` methods to open. Or open manually with `I.openEmail()` method.\n\n#### Parameters\n\n-   `text`  \n\n### seeEmailSubjectEquals\n\nChecks that current email subject equals to text.\n\n```js\nI.seeEmailSubjectEquals('Restore password');\n```\n\nRequires an opened email. Use either `waitForEmail*` methods to open. Or open manually with `I.openEmail()` method.\n\n#### Parameters\n\n-   `text`  \n\n### dontSeeEmailSubjectEquals\n\nChecks that current email subject doesn't equal to text.\n\n```js\nI.dontSeeEmailSubjectEquals('Restore password');\n```\n\nRequires an opened email. Use either `waitForEmail*` methods to open. Or open manually with `I.openEmail()` method.\n\n#### Parameters\n\n-   `text`  \n\n### seeNumberOfEmailAttachments\n\nChecks that current email has expected number of attachments.\n\n```js\nI.seeNumberOfEmailAttachments(2);\n```\n\nRequires an opened email. Use either `waitForEmail*` methods to open. Or open manually with `I.openEmail()` method.\n\n#### Parameters\n\n-   `number`  \n\n### seeEmailAttachment\n\nChecks that current email has an attachment with specified name.\n\n```js\nI.seeEmailAttachment('ExampleAttachment.pdf');\n```\n\nBe aware that Mailslurp SDK removes special characters in name of attachment,\ne.g. \"Example-Attachment.pdf\" will have name \"ExampleAttachment.pdf\".\n\nRequires an opened email. Use either `waitForEmail*` methods to open. Or open manually with `I.openEmail()` method.\n\n#### Parameters\n\n-   `nameRegExp`  \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeceptjs%2Fmailslurp-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeceptjs%2Fmailslurp-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeceptjs%2Fmailslurp-helper/lists"}