e2e-mail 0.0.1 → 0.0.3
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/dist/core/api/mailtm-api.d.ts +1528 -0
- package/dist/core/api/mailtm-api.d.ts.map +1 -0
- package/dist/core/mailtm/index.d.ts +46 -0
- package/dist/core/mailtm/index.d.ts.map +1 -0
- package/dist/core/mailtm/utils.d.ts +29 -0
- package/dist/core/mailtm/utils.d.ts.map +1 -0
- package/dist/cypress/index.d.ts +32 -0
- package/dist/cypress/index.d.ts.map +1 -0
- package/dist/cypress.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/playwright/index.d.ts +27 -0
- package/dist/playwright/index.d.ts.map +1 -0
- package/dist/playwright.js.map +1 -1
- package/package.json +10 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailtm-api.d.ts","sourceRoot":"","sources":["../../../src/core/api/mailtm-api.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,GAAG,CAAC;AAOxC;;WAEW;AACX,wBAAsB,UAAU;;;;;;;;;;GAQ/B;AAED;;YAEY;AACZ,wBAAsB,aAAa,CAAC,EAClC,OAAO,EACP,QAAQ,GACT,EAAE,cAAc,CAAC,mBAAmB,CAAC;;;;;;;;;;;;GAYrC;AAED,wBAAsB,KAAK,CAAC,KAAK,EAAE,MAAM;;;;;;;;;;;;GASxC;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;GAc5D;AAED;;UAEU;AACV,wBAAsB,WAAW,CAAC,EAChC,OAAO,EACP,QAAQ,GACT,EAAE,cAAc,CAAC,kBAAkB,CAAC;;;;;GAYpC;AAED;;aAEa;AACb,wBAAsB,WAAW,CAAC,KAAK,EAAE,MAAM;;;;;;;;;;;;;;;;;;;GAS9C;AAED,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAczD;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;GAc5D;AAED;;WAEW;AACX,wBAAsB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;;;;GAcxD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { PollingOptions, SearchFilters } from './mailtm.d';
|
|
2
|
+
export declare class E2EMailClient {
|
|
3
|
+
private static readonly POLL_INTERVAL;
|
|
4
|
+
private address;
|
|
5
|
+
private password;
|
|
6
|
+
private token;
|
|
7
|
+
private accountId;
|
|
8
|
+
constructor(address: string, password: string);
|
|
9
|
+
private login;
|
|
10
|
+
/** Initializes mailbox with existing credentials. If new and available account, it will be created automatically */
|
|
11
|
+
initialize(): Promise<void>;
|
|
12
|
+
dispose(): Promise<{
|
|
13
|
+
data: undefined;
|
|
14
|
+
error: undefined;
|
|
15
|
+
}>;
|
|
16
|
+
/** Fetch and filter emails for the initialized mailbox and return most recent match */
|
|
17
|
+
private queryMessages;
|
|
18
|
+
/** Poll for messages in the initialized mailbox and timeout */
|
|
19
|
+
pollMessages(filters?: SearchFilters, { timeout, autoDelete }?: PollingOptions): Promise<{
|
|
20
|
+
readonly id?: string | undefined;
|
|
21
|
+
msgid?: string | undefined;
|
|
22
|
+
from?: unknown;
|
|
23
|
+
to?: unknown[][] | undefined;
|
|
24
|
+
cc?: unknown[][] | undefined;
|
|
25
|
+
bcc?: unknown[][] | undefined;
|
|
26
|
+
subject?: string | undefined;
|
|
27
|
+
intro?: string | undefined;
|
|
28
|
+
seen?: boolean | undefined;
|
|
29
|
+
flagged?: boolean | undefined;
|
|
30
|
+
isDeleted?: boolean | undefined;
|
|
31
|
+
verifications?: string[] | undefined;
|
|
32
|
+
retention?: boolean | undefined;
|
|
33
|
+
retentionDate?: string | undefined;
|
|
34
|
+
text?: string | undefined;
|
|
35
|
+
html?: string[] | undefined;
|
|
36
|
+
hasAttachments?: boolean | undefined;
|
|
37
|
+
attachments?: unknown[][] | undefined;
|
|
38
|
+
size?: number | undefined;
|
|
39
|
+
downloadUrl?: string | undefined;
|
|
40
|
+
sourceUrl?: string | null | undefined;
|
|
41
|
+
createdAt?: string | undefined;
|
|
42
|
+
updatedAt?: string | undefined;
|
|
43
|
+
accountId?: string | undefined;
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/mailtm/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhE,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAQ;IAC7C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,SAAS,CAAqB;gBAE1B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;YAK/B,KAAK;IAcnB,oHAAoH;IACvG,UAAU;IAiBV,OAAO;;;;IASpB,uFAAuF;YACzE,aAAa;IAiB3B,+DAA+D;IAClD,YAAY,CACvB,OAAO,CAAC,EAAE,aAAa,EACvB,EAAE,OAAe,EAAE,UAAiB,EAAE,GAAE,cAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;CAwB9D"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ResponseData } from '../api';
|
|
2
|
+
import { SearchFilters } from './mailtm.d';
|
|
3
|
+
/** Determines if passed email domain matches any active domains from mail.tm, fail if not
|
|
4
|
+
* @remarks This is intentionally bypassed if a token was successfully created for a previously established account whose domain was deactivated
|
|
5
|
+
* @param address The email address for which to check domain validitity
|
|
6
|
+
*/
|
|
7
|
+
export declare const validateEmailDomain: (address: string) => Promise<string>;
|
|
8
|
+
/** Search and filter account messages by message metadata or content
|
|
9
|
+
* @param messages The messages returned from the account to filter
|
|
10
|
+
* @param filters The filtering criteria to apply to the messages
|
|
11
|
+
*/
|
|
12
|
+
export declare function filterMessages(messages?: ResponseData<"api_messages_get_collection", 200>, filters?: SearchFilters): {
|
|
13
|
+
readonly id?: string;
|
|
14
|
+
msgid?: string;
|
|
15
|
+
from?: unknown;
|
|
16
|
+
to?: unknown[][];
|
|
17
|
+
subject?: string;
|
|
18
|
+
intro?: string;
|
|
19
|
+
seen?: boolean;
|
|
20
|
+
isDeleted?: boolean;
|
|
21
|
+
hasAttachments?: boolean;
|
|
22
|
+
size?: number;
|
|
23
|
+
downloadUrl?: string;
|
|
24
|
+
sourceUrl?: string | null;
|
|
25
|
+
createdAt?: string;
|
|
26
|
+
updatedAt?: string;
|
|
27
|
+
accountId?: string;
|
|
28
|
+
}[];
|
|
29
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/core/mailtm/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAU,SAAS,MAAM,oBAaxD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,GAAE,YAAY,CAAC,6BAA6B,EAAE,GAAG,CAAM,EAC/D,OAAO,CAAC,EAAE,aAAa;;;;;;;;;;;;;;;;IAqCxB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PollingOptions, SearchFilters } from '../core/mailtm/mailtm';
|
|
2
|
+
import { components } from '../core/api/mailtm-api.d';
|
|
3
|
+
type Message = components["schemas"]["Message-message.read"];
|
|
4
|
+
declare global {
|
|
5
|
+
namespace Cypress {
|
|
6
|
+
interface Chainable {
|
|
7
|
+
/**
|
|
8
|
+
* Initialize mailbox session
|
|
9
|
+
* @param address Email address
|
|
10
|
+
* @param password Account password
|
|
11
|
+
*/
|
|
12
|
+
initializeMailbox(address: string, password: string): void;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get most recent inbox match for an existing or new mail account
|
|
16
|
+
* @param filters Optional search filters
|
|
17
|
+
* @param options Configuration for message polling
|
|
18
|
+
*/
|
|
19
|
+
searchMailbox(
|
|
20
|
+
filters?: SearchFilters,
|
|
21
|
+
options?: PollingOptions,
|
|
22
|
+
): Chainable<Message>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Delete the account mailbox and all its emails from the server
|
|
26
|
+
*/
|
|
27
|
+
removeMailbox(): Chainable<void>;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cypress/index.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,CAAC"}
|
package/dist/cypress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cypress.js","sources":["../src/cypress/index.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"cypress.js","sources":["../src/cypress/index.ts"],"sourcesContent":["import { E2EMailClient } from \"../core/mailtm\";\nimport \"./index.d\";\n\nlet mailClient: E2EMailClient | null = null;\n\nCypress.Commands.add(\"initializeMailbox\", (address, password) => {\n cy.log(`Creating mailbox ${address}`);\n\n return cy.then(async () => {\n mailClient = new E2EMailClient(address, password);\n await mailClient.initialize();\n });\n});\n\nCypress.Commands.add(\"removeMailbox\", () => {\n return cy.then(async () => {\n if (!mailClient) {\n throw new Error(\n \"Mailbox client not initialized. Call cy.initializeMailbox() first.\",\n );\n }\n\n await 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 + 1000 }, 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 return message;\n });\n});\n"],"names":["mailClient","address","password","E2EMailClient","filters","options","timeout","autoDelete","message","html","doc"],"mappings":";AAGA,IAAIA,IAAmC;AAEvC,QAAQ,SAAS,IAAI,qBAAqB,CAACC,GAASC,OAClD,GAAG,IAAI,oBAAoBD,CAAO,EAAE,GAE7B,GAAG,KAAK,YAAY;AACzB,EAAAD,IAAa,IAAIG,EAAcF,GAASC,CAAQ,GAChD,MAAMF,EAAW,WAAA;AACnB,CAAC,EACF;AAED,QAAQ,SAAS,IAAI,iBAAiB,MAC7B,GAAG,KAAK,YAAY;AACzB,MAAI,CAACA;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAIJ,QAAMA,EAAW,QAAA;AACnB,CAAC,CACF;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,WAAIC,KACF,GAAG,SAAA,EAAW,KAAK,CAACC,MAAQ;AAC1B,MAAAA,EAAI,KAAA,GACJA,EAAI,MAAM,OAAOD,CAAI,CAAC,GACtBC,EAAI,MAAA;AAAA,IACN,CAAC,GAGIF;AAAA,EACT,CAAC;AACH,CAAC;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PollingOptions, SearchFilters } from '../core/mailtm/mailtm';
|
|
2
|
+
import { components } from '../core/api/mailtm-api.d';
|
|
3
|
+
type Message = components["schemas"]["Message-message.read"];
|
|
4
|
+
|
|
5
|
+
export type MailFixtures = {
|
|
6
|
+
/**
|
|
7
|
+
* Initialize mailbox session
|
|
8
|
+
* @param address Email address
|
|
9
|
+
* @param password Account password
|
|
10
|
+
*/
|
|
11
|
+
initializeMailbox: (address: string, password: string) => void;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get most recent inbox match for an existing or new mail account
|
|
15
|
+
* @param filters Optional search filters
|
|
16
|
+
* @param options Configuration for message polling
|
|
17
|
+
*/
|
|
18
|
+
searchMailbox: (
|
|
19
|
+
filters?: SearchFilters,
|
|
20
|
+
options?: PollingOptions,
|
|
21
|
+
) => Promise<Message>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Delete the account mailbox and all its emails from the server
|
|
25
|
+
*/
|
|
26
|
+
removeMailbox: () => void;
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/playwright/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAI9C,eAAO,MAAM,IAAI,uPA8Cf,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/playwright.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwright.js","sources":["../src/playwright/index.ts"],"sourcesContent":["import { test as base } from \"@playwright/test\";\nimport
|
|
1
|
+
{"version":3,"file":"playwright.js","sources":["../src/playwright/index.ts"],"sourcesContent":["import { test as base } from \"@playwright/test\";\nimport { E2EMailClient } from \"../core/mailtm\";\nimport type { MailFixtures } from \"./index.d\";\n\nlet mailClient: E2EMailClient | undefined;\n\nexport const test = base.extend<MailFixtures>({\n initializeMailbox: async ({}, use) => {\n await use(async (address, password) => {\n mailClient = new E2EMailClient(address, password);\n await mailClient.initialize();\n });\n },\n\n removeMailbox: async ({}, use) => {\n await use(async () => {\n if (!mailClient) {\n throw new Error(\n \"Mailbox client not initialized. Call initializeMailbox() first.\",\n );\n }\n\n await mailClient.dispose();\n });\n },\n\n searchMailbox: async ({ page }, use) => {\n await use(async (filters, options = {}) => {\n const {\n timeout = test.info().project.use.actionTimeout ?? 4000,\n autoDelete,\n } = options;\n\n if (!mailClient) {\n throw new Error(\n \"Mailbox client not initialized. Call initializeMailbox() first.\",\n );\n }\n\n const message = await mailClient.pollMessages(filters, {\n timeout,\n autoDelete,\n });\n const html = message.html?.[0] ?? message.html ?? \"\";\n\n if (html) {\n await page.setContent(String(html));\n }\n\n return message;\n });\n },\n});\n\nexport { expect } from \"@playwright/test\";\n"],"names":["mailClient","test","base","use","address","password","E2EMailClient","page","filters","options","timeout","autoDelete","message","html","_a"],"mappings":";;;AAIA,IAAIA;AAEG,MAAMC,IAAOC,EAAK,OAAqB;AAAA,EAC5C,mBAAmB,OAAO,CAAA,GAAIC,MAAQ;AACpC,UAAMA,EAAI,OAAOC,GAASC,MAAa;AACrC,MAAAL,IAAa,IAAIM,EAAcF,GAASC,CAAQ,GAChD,MAAML,EAAW,WAAA;AAAA,IACnB,CAAC;AAAA,EACH;AAAA,EAEA,eAAe,OAAO,CAAA,GAAIG,MAAQ;AAChC,UAAMA,EAAI,YAAY;AACpB,UAAI,CAACH;AACH,cAAM,IAAI;AAAA,UACR;AAAA,QAAA;AAIJ,YAAMA,EAAW,QAAA;AAAA,IACnB,CAAC;AAAA,EACH;AAAA,EAEA,eAAe,OAAO,EAAE,MAAAO,EAAA,GAAQJ,MAAQ;AACtC,UAAMA,EAAI,OAAOK,GAASC,IAAU,CAAA,MAAO;;AACzC,YAAM;AAAA,QACJ,SAAAC,IAAUT,EAAK,KAAA,EAAO,QAAQ,IAAI,iBAAiB;AAAA,QACnD,YAAAU;AAAA,MAAA,IACEF;AAEJ,UAAI,CAACT;AACH,cAAM,IAAI;AAAA,UACR;AAAA,QAAA;AAIJ,YAAMY,IAAU,MAAMZ,EAAW,aAAaQ,GAAS;AAAA,QACrD,SAAAE;AAAA,QACA,YAAAC;AAAA,MAAA,CACD,GACKE,MAAOC,IAAAF,EAAQ,SAAR,gBAAAE,EAAe,OAAMF,EAAQ,QAAQ;AAElD,aAAIC,KACF,MAAMN,EAAK,WAAW,OAAOM,CAAI,CAAC,GAG7BD;AAAA,IACT,CAAC;AAAA,EACH;AACF,CAAC;"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "e2e-mail",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "A zero-config solution for testing email in major testing frameworks.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
9
10
|
"import": "./dist/index.js"
|
|
10
11
|
},
|
|
11
12
|
"./cypress": {
|
|
12
|
-
"
|
|
13
|
+
"types": "./dist/cypress/index.d.ts",
|
|
14
|
+
"import": "./dist/cypress.js"
|
|
13
15
|
},
|
|
14
16
|
"./playwright": {
|
|
15
|
-
"
|
|
17
|
+
"types": "./dist/playwright/index.d.ts",
|
|
18
|
+
"import": "./dist/playwright.js"
|
|
16
19
|
}
|
|
17
20
|
},
|
|
18
21
|
"files": [
|
|
@@ -39,11 +42,14 @@
|
|
|
39
42
|
"devDependencies": {
|
|
40
43
|
"@playwright/test": "^1.49.0",
|
|
41
44
|
"@types/node": "^25.9.2",
|
|
45
|
+
"e2e-mail": "^0.0.2",
|
|
42
46
|
"openapi-fetch": "^0.17.0",
|
|
43
47
|
"openapi-typescript": "^7.13.0",
|
|
44
48
|
"tsx": "^4.22.4",
|
|
45
49
|
"typescript": "^5.9.3",
|
|
46
|
-
"vite": "^6.3.0"
|
|
50
|
+
"vite": "^6.3.0",
|
|
51
|
+
"vite-plugin-dts": "^5.0.2",
|
|
52
|
+
"vite-tsconfig-paths": "^6.1.1"
|
|
47
53
|
},
|
|
48
54
|
"peerDependencies": {
|
|
49
55
|
"cypress": "^15",
|