@tempyemail/e2e-testing 1.0.0

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.
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pollUntil = pollUntil;
4
+ exports.wait = wait;
5
+ /**
6
+ * Poll a function until it returns a non-null value or timeout is reached
7
+ * Supports exponential backoff for efficient polling
8
+ */
9
+ async function pollUntil(fn, options = {}) {
10
+ const { timeout = 30000, interval = 1000, maxInterval = 5000, backoff = true, } = options;
11
+ const startTime = Date.now();
12
+ let currentInterval = interval;
13
+ while (true) {
14
+ const result = await fn();
15
+ if (result !== null) {
16
+ return result;
17
+ }
18
+ const elapsed = Date.now() - startTime;
19
+ if (elapsed >= timeout) {
20
+ throw new Error(`Polling timeout after ${timeout}ms`);
21
+ }
22
+ // Wait for the current interval
23
+ await new Promise((resolve) => setTimeout(resolve, currentInterval));
24
+ // Apply exponential backoff if enabled
25
+ if (backoff) {
26
+ currentInterval = Math.min(currentInterval * 1.5, maxInterval);
27
+ }
28
+ }
29
+ }
30
+ /**
31
+ * Wait for a specific amount of time
32
+ */
33
+ async function wait(ms) {
34
+ return new Promise((resolve) => setTimeout(resolve, ms));
35
+ }
36
+ //# sourceMappingURL=polling.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polling.js","sourceRoot":"","sources":["../../src/utils/polling.ts"],"names":[],"mappings":";;AAMA,8BAiCC;AAKD,oBAEC;AA5CD;;;GAGG;AACI,KAAK,UAAU,SAAS,CAC7B,EAA2B,EAC3B,UAAuB,EAAE;IAEzB,MAAM,EACJ,OAAO,GAAG,KAAK,EACf,QAAQ,GAAG,IAAI,EACf,WAAW,GAAG,IAAI,EAClB,OAAO,GAAG,IAAI,GACf,GAAG,OAAO,CAAC;IAEZ,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,IAAI,eAAe,GAAG,QAAQ,CAAC;IAE/B,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,MAAM,GAAG,MAAM,EAAE,EAAE,CAAC;QAC1B,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QACvC,IAAI,OAAO,IAAI,OAAO,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,yBAAyB,OAAO,IAAI,CAAC,CAAC;QACxD,CAAC;QAED,gCAAgC;QAChC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;QAErE,uCAAuC;QACvC,IAAI,OAAO,EAAE,CAAC;YACZ,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,GAAG,GAAG,EAAE,WAAW,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,IAAI,CAAC,EAAU;IACnC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@tempyemail/e2e-testing",
3
+ "version": "1.0.0",
4
+ "description": "JavaScript client for tempy.email - temporary email addresses for automated E2E testing",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "README.md",
10
+ "LICENSE"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "prepublishOnly": "npm run build",
15
+ "clean": "rm -rf dist"
16
+ },
17
+ "keywords": [
18
+ "email",
19
+ "testing",
20
+ "e2e",
21
+ "temporary",
22
+ "disposable",
23
+ "playwright",
24
+ "cypress",
25
+ "jest",
26
+ "vitest",
27
+ "otp",
28
+ "verification",
29
+ "2fa",
30
+ "automation"
31
+ ],
32
+ "author": "TempyEmail",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/TempyEmail/e2e-testing.git"
37
+ },
38
+ "bugs": {
39
+ "url": "https://github.com/TempyEmail/e2e-testing/issues"
40
+ },
41
+ "homepage": "https://tempy.email",
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^20.11.0",
47
+ "typescript": "^5.3.3"
48
+ },
49
+ "engines": {
50
+ "node": ">=16.0.0"
51
+ }
52
+ }