e2e-mail 0.0.16 โ 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
# e2e-mail
|
|
2
1
|
<p align="center">
|
|
3
|
-
<img width="256" height="256" alt="
|
|
2
|
+
<img width="256" height="256" alt="Screenshot 2026-06-19 at 1 16 02โฏAM" src="https://github.com/user-attachments/assets/171830fc-c2b9-4d94-ab6e-bda89c033364" />
|
|
4
3
|
</p>
|
|
5
4
|
|
|
6
5
|
<h2 align="center">
|
|
@@ -23,14 +22,95 @@ By leveraging free temporary email infrastructure behind a developer-friendly AP
|
|
|
23
22
|
|
|
24
23
|
Whether you're testing account verification flows, password resets, magic links, invitations, or transactional emails, E2E Mail helps you validate real email delivery inside your end-to-end tests with just a few lines of code.
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
# Usage
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
```bash
|
|
28
|
+
npm i e2e-mail
|
|
29
|
+
```
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
### Cypress
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
```ts
|
|
34
|
+
import "e2e-mail/cypress"; // Or globally wherever you import commands
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
describe("Mail.tm Integration", () => {
|
|
37
|
+
it("fetches the most recent and relevant message", () => {
|
|
38
|
+
/* STEP 1 */
|
|
39
|
+
cy.initializeMailbox("someusername@<valid-domain>", "Pass1234");
|
|
35
40
|
|
|
36
|
-
|
|
41
|
+
/* Test script continues until app sends email */
|
|
42
|
+
|
|
43
|
+
/* STEP 2 */
|
|
44
|
+
cy.searchMailbox(
|
|
45
|
+
{
|
|
46
|
+
subject: "", // Optional - Subject Filter
|
|
47
|
+
recipient: "", // Optional - Recipient Filter
|
|
48
|
+
sender: "", // Optional - Sender Filter
|
|
49
|
+
createdAfter: "", // - Optional Min Date Filter
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
timeout: 15000 // Optional - How long to poll for a match
|
|
53
|
+
autoDelete: false // Optional - Delete after fetching (Defaults true)
|
|
54
|
+
},
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
/* STEP 3 (OPTIONAL) */
|
|
58
|
+
cy.removeMailbox()
|
|
59
|
+
|
|
60
|
+
/* Renders email DOM accepting assertions and interactions */
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Playwright
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import { test, expect } from "e2e-mail/playwright";
|
|
69
|
+
|
|
70
|
+
test.describe("Mail.tm Integration", () => {
|
|
71
|
+
test("fetches the most recent and relevant message", async ({
|
|
72
|
+
initializeMailbox,
|
|
73
|
+
searchMailbox,
|
|
74
|
+
removeMailbox
|
|
75
|
+
}) => {
|
|
76
|
+
/* STEP 1 */
|
|
77
|
+
await initializeMailbox("someusername@<valid-domain>", "Pass1234");
|
|
78
|
+
|
|
79
|
+
/* Test script continues until app sends email */
|
|
80
|
+
|
|
81
|
+
/* STEP 2 */
|
|
82
|
+
await searchMailbox(
|
|
83
|
+
{
|
|
84
|
+
subject: "", // Optional - Subject Filter
|
|
85
|
+
recipient: "", // Optional - Recipient Filter
|
|
86
|
+
sender: "", // Optional - Sender Filter
|
|
87
|
+
createdAfter: "", // - Optional Min Date Filter
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
timeout: 15000 // Optional - How long to poll for a match
|
|
91
|
+
autoDelete: false // Optional - Delete after fetching (Defaults true)
|
|
92
|
+
},
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
/* STEP 3 (OPTIONAL) */
|
|
96
|
+
await removeMailbox()
|
|
97
|
+
|
|
98
|
+
/* Renders email DOM accepting assertions and interactions */
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
That's it... Seriously!
|
|
104
|
+
|
|
105
|
+
# Tips
|
|
106
|
+
|
|
107
|
+
### I have multiple tests sharing an inbox and want to uniquely identify their emails.
|
|
108
|
+
|
|
109
|
+
Email subaddressing is supported here. Add your unique identifier to your email like `test+<any-string-identifier>@example.com` and then
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
searchMailbox({
|
|
113
|
+
recipient: "test+<any-string-identifier>@example.com",
|
|
114
|
+
// ...additional filters
|
|
115
|
+
});
|
|
116
|
+
```
|
|
@@ -13,8 +13,6 @@ export type SearchFilters = {
|
|
|
13
13
|
export type PollingOptions = {
|
|
14
14
|
/** Timeout before exisitng polling loop */
|
|
15
15
|
timeout?: number;
|
|
16
|
-
/** Interval for polling search */
|
|
17
|
-
interval?: number;
|
|
18
16
|
/** If true, delete the email immediately when fetched
|
|
19
17
|
* @default true
|
|
20
18
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/mailtm/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/mailtm/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC"}
|
package/dist/cypress.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { E2EMailClient as s } from "./core/mailtm/index.js";
|
|
2
2
|
let i = null;
|
|
3
3
|
Cypress.Commands.add("initializeMailbox", (e, t) => {
|
|
4
|
-
cy.
|
|
4
|
+
cy.log(`Initializing mailbox ${e}`), cy.then(() => (i = new s(e, t), i.initialize()));
|
|
5
5
|
});
|
|
6
6
|
Cypress.Commands.add("removeMailbox", () => {
|
|
7
7
|
cy.then(() => {
|
package/dist/cypress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cypress.js","sources":["../src/cypress/cypress.ts"],"sourcesContent":["import { E2EMailClient } from \"../core/mailtm\";\nimport type { PollingOptions, SearchFilters } from \"../core/mailtm/types\";\n\nlet mailClient: E2EMailClient | null = null;\ndeclare global {\n namespace Cypress {\n interface Chainable {\n /**\n * Initialize mailbox session\n * @param address Email address\n * @param password Account password\n */\n initializeMailbox(address: string, password: string): Chainable<void>;\n\n /**\n * Get most recent inbox match for an existing or new mail account\n * @param filters Optional search filters\n * @param options Configuration for message polling\n */\n searchMailbox(\n filters?: SearchFilters,\n options?: PollingOptions,\n ): Chainable<void>;\n\n /**\n * Delete the account mailbox and all its emails from the server\n */\n removeMailbox(): Chainable<void>;\n }\n }\n}\n\nCypress.Commands.add(\"initializeMailbox\", (address, password) => {\n cy.
|
|
1
|
+
{"version":3,"file":"cypress.js","sources":["../src/cypress/cypress.ts"],"sourcesContent":["import { E2EMailClient } from \"../core/mailtm\";\nimport type { PollingOptions, SearchFilters } from \"../core/mailtm/types\";\n\nlet mailClient: E2EMailClient | null = null;\ndeclare global {\n namespace Cypress {\n interface Chainable {\n /**\n * Initialize mailbox session\n * @param address Email address\n * @param password Account password\n */\n initializeMailbox(address: string, password: string): Chainable<void>;\n\n /**\n * Get most recent inbox match for an existing or new mail account\n * @param filters Optional search filters\n * @param options Configuration for message polling\n */\n searchMailbox(\n filters?: SearchFilters,\n options?: PollingOptions,\n ): Chainable<void>;\n\n /**\n * Delete the account mailbox and all its emails from the server\n */\n removeMailbox(): Chainable<void>;\n }\n }\n}\n\nCypress.Commands.add(\"initializeMailbox\", (address, password) => {\n cy.log(`Initializing mailbox ${address}`);\n\n cy.then(() => {\n mailClient = new E2EMailClient(address, password);\n return mailClient.initialize();\n });\n});\n\nCypress.Commands.add(\"removeMailbox\", () => {\n cy.then(() => {\n if (!mailClient) {\n throw new Error(\n \"Mailbox client not initialized. Call cy.initializeMailbox() first.\",\n );\n }\n\n return mailClient.dispose();\n });\n});\n\nCypress.Commands.add(\"searchMailbox\", (filters, options = {}) => {\n const {\n timeout = Cypress.config().defaultCommandTimeout ?? 4000,\n autoDelete,\n } = options;\n\n return cy.then({ timeout: timeout + 2000 }, async () => {\n if (!mailClient) {\n throw new Error(\n \"Mailbox client not initialized. Call cy.initializeMailbox() first.\",\n );\n }\n\n // Get most recent match\n const message = await mailClient.pollMessages(filters, {\n timeout,\n autoDelete,\n });\n const html = Array.isArray(message.html) ? message.html[0] : message.html;\n\n // Write HTML to Cypress DOM\n if (html) {\n cy.document().then((doc) => {\n doc.open();\n doc.write(String(html));\n doc.close();\n });\n }\n });\n});\n"],"names":["mailClient","address","password","E2EMailClient","filters","options","timeout","autoDelete","message","html","doc"],"mappings":";AAGA,IAAIA,IAAmC;AA6BvC,QAAQ,SAAS,IAAI,qBAAqB,CAACC,GAASC,MAAa;AAC/D,KAAG,IAAI,wBAAwBD,CAAO,EAAE,GAExC,GAAG,KAAK,OACND,IAAa,IAAIG,EAAcF,GAASC,CAAQ,GACzCF,EAAW,WAAA,EACnB;AACH,CAAC;AAED,QAAQ,SAAS,IAAI,iBAAiB,MAAM;AAC1C,KAAG,KAAK,MAAM;AACZ,QAAI,CAACA;AACH,YAAM,IAAI;AAAA,QACR;AAAA,MAAA;AAIJ,WAAOA,EAAW,QAAA;AAAA,EACpB,CAAC;AACH,CAAC;AAED,QAAQ,SAAS,IAAI,iBAAiB,CAACI,GAASC,IAAU,OAAO;AAC/D,QAAM;AAAA,IACJ,SAAAC,IAAU,QAAQ,OAAA,EAAS,yBAAyB;AAAA,IACpD,YAAAC;AAAA,EAAA,IACEF;AAEJ,SAAO,GAAG,KAAK,EAAE,SAASC,IAAU,IAAA,GAAQ,YAAY;AACtD,QAAI,CAACN;AACH,YAAM,IAAI;AAAA,QACR;AAAA,MAAA;AAKJ,UAAMQ,IAAU,MAAMR,EAAW,aAAaI,GAAS;AAAA,MACrD,SAAAE;AAAA,MACA,YAAAC;AAAA,IAAA,CACD,GACKE,IAAO,MAAM,QAAQD,EAAQ,IAAI,IAAIA,EAAQ,KAAK,CAAC,IAAIA,EAAQ;AAGrE,IAAIC,KACF,GAAG,SAAA,EAAW,KAAK,CAACC,MAAQ;AAC1B,MAAAA,EAAI,KAAA,GACJA,EAAI,MAAM,OAAOD,CAAI,CAAC,GACtBC,EAAI,MAAA;AAAA,IACN,CAAC;AAAA,EAEL,CAAC;AACH,CAAC;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "e2e-mail",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "A zero-config solution for testing email in major testing frameworks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -59,10 +59,9 @@
|
|
|
59
59
|
"license": "MIT",
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@playwright/test": "^1.49.0",
|
|
62
|
-
"@types/node": "^25.9.
|
|
62
|
+
"@types/node": "^25.9.3",
|
|
63
63
|
"cypress": "^15.17.0",
|
|
64
|
-
"e2e-mail": "^0.0.
|
|
65
|
-
"openapi-fetch": "^0.17.0",
|
|
64
|
+
"e2e-mail": "^0.0.18",
|
|
66
65
|
"openapi-typescript": "^7.13.0",
|
|
67
66
|
"tsx": "^4.22.4",
|
|
68
67
|
"typescript": "^5.9.0",
|
|
@@ -81,5 +80,8 @@
|
|
|
81
80
|
"playwright": {
|
|
82
81
|
"optional": true
|
|
83
82
|
}
|
|
83
|
+
},
|
|
84
|
+
"dependencies": {
|
|
85
|
+
"openapi-fetch": "^0.17.0"
|
|
84
86
|
}
|
|
85
87
|
}
|