{"id":15764572,"url":"https://github.com/pavkam/codeceptjs-testmailapp-helper","last_synced_at":"2025-05-07T02:40:59.382Z","repository":{"id":56491079,"uuid":"303426500","full_name":"pavkam/codeceptjs-testmailapp-helper","owner":"pavkam","description":"Codecept.js email helper for Testmail.app","archived":false,"fork":false,"pushed_at":"2024-10-29T14:35:33.000Z","size":146,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-22T15:09:15.034Z","etag":null,"topics":["codeceptjs","testmail"],"latest_commit_sha":null,"homepage":"","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/pavkam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2020-10-12T14:59:58.000Z","updated_at":"2024-10-29T14:36:14.000Z","dependencies_parsed_at":"2024-10-25T11:37:55.446Z","dependency_job_id":"a400586d-db75-4634-8452-3a9bb52156fc","html_url":"https://github.com/pavkam/codeceptjs-testmailapp-helper","commit_stats":{"total_commits":11,"total_committers":3,"mean_commits":"3.6666666666666665","dds":"0.18181818181818177","last_synced_commit":"ca06a28c1b5368234bb01c22782117a732de6357"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pavkam%2Fcodeceptjs-testmailapp-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pavkam%2Fcodeceptjs-testmailapp-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pavkam%2Fcodeceptjs-testmailapp-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pavkam%2Fcodeceptjs-testmailapp-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pavkam","download_url":"https://codeload.github.com/pavkam/codeceptjs-testmailapp-helper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252802423,"owners_count":21806497,"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","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":["codeceptjs","testmail"],"created_at":"2024-10-04T12:04:07.390Z","updated_at":"2025-05-07T02:40:59.360Z","avatar_url":"https://github.com/pavkam.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Testmail.app helper for CodeceptJS\n\n[CodeceptJs](https://codecept.io) helper for end-to-end testing using the [Testmail.app service](https://testmail.app).\nTestmail service does not create disposable inboxes as other services do, but their namespace/tag support allows this helper to simulate\ninbox creation.\n\n## Setup\n\nFirst, create an account with [Testmail.app](https://testmail.app) and obtain your API key and the namespace that you will use for testing.\nThen, install the helper using the following command:\n\n```shell\nnpm i codeceptjs-testmailapp-helper --save\n```\n\nAdd the helper to your `codecept.conf.js` file:\n\n```js\nhelpers: {\n  TestmailHelper: {\n    apiKey: '\u003ctestmail.app API key\u003e',\n    namespace: '\u003ctestmail.app namespace\u003e',\n    require: 'codeceptjs-testmailapp-helper'\n  },\n}\n```\n\n## The simplest use case\n\nThe following code will allow your test to create a new random inbox and then receive an email:\n\n```js\nconst inbox = await I.haveInbox();\n\n// Trigger some code that will send an email\nawait I.needNotification(inbox.email);\n\n// Wait for the email to be received.\nconst email = await I.receiveEmail();\n\n// check that sender is the expected one.\nassert(email.from === \"Notifications \u003cnotify@company.com\u003e\");\n```\n\n## Functions\n\nThe helper exposes only three functions you should care about. They are listed below.\n\n### `haveInbox()`\n\nCreates a new inbox. The email address is generated using the account namespace, a random tag and the standard testmail.app domain.\nThe function returns an `inbox` object that you can use later in the other functions.\n\nExample:\n\n```js\nconst inbox = await I.haveInbox();\n\n// Use the inbox.email to obtain the generated random email.\nI.say(`The new email is ${inbox.email}.`);\n```\n\n### `haveInbox(email)`\n\nRe-creates an inbox from a given email address. The email address is expected to be using the same account namespace, a tag and the standard testmail.app domain.\nThe function return an `inbox` object that you can use later in the other functions.\n\nThis function is useful to when receiving emails for previously created accounts.\n\nExample:\n\n```js\nconst inbox = await I.haveInbox(\"abcde.4347sddsd1@inbox.testmail.app\");\n\n// Use the inbox.email to obtain the same email.\nI.say(`The new email is ${inbox.email}.`);\n```\n\n### `receiveEmails()`\n\nWaits and returns all new emails since the last call to `receiveEmails()`. Note that calling this function without an inbox argument will assume the \nemails are loaded for the inbox that was last created using `haveInbox()` function.\n\nIf no emails are retrieved in the given timeout period, an error is raised.\n\nExample:\n\n```js\nconst emails = await I.receiveEmails();\n\n// use the properties from the email.\nassert(emails[0].from === \"me\");\n```\n\n### `receiveEmails(inbox, [timeout])`\n\nWaits for all new emails since last call to `receiveEmails()` for a given inbox. The inbox has to be created beforehand using the `haveInbox()` function.\nYou can supply a timeout (in seconds) as the last argument to this function.\n\nIf no emails are retrieved in the given timeout period, an error is raised.\n\nExample:\n\n```js\nconst inbox = await I.haveInbox();\n// tests ...\nconst emails = await I.receiveEmails(inbox, 60); // only wait 60 seconds.\n\n// use the properties from the email.\nassert(emails[0].from === \"me\");\n```\n\n### `receiveEmail()` / `receiveEmail(inbox, [timeout])`\n\nAnd, because waiting for multiple emails is not very useful, there is a version of the function that only returns the latest received email.\n\nIf no emails are retrieved in the given timeout period, an error is raised.\n\nExample:\n\n```js\nconst email = await I.receiveEmail();\n\n// use the properties from the email.\nassert(email[0].from === \"me\");\n```\n\n### The `email` object\n\nThe email object consists from the following properties:\n\n```none\n{\n    from,\n    subject,\n    html,\n    text,\n    attachments {\n      filename\n      contentType\n      downloadUrl\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpavkam%2Fcodeceptjs-testmailapp-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpavkam%2Fcodeceptjs-testmailapp-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpavkam%2Fcodeceptjs-testmailapp-helper/lists"}