twd-js 1.2.2 → 1.2.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/index.cjs.js +25 -25
- package/dist/index.d.ts +6 -2
- package/dist/index.es.js +638 -623
- package/dist/mock-sw.js +1 -1
- package/dist/runner-ci.cjs.js +1 -1
- package/dist/runner-ci.es.js +22 -33
- package/package.json +6 -7
- package/dist/_commonjsHelpers-C6fGbg64.mjs +0 -6
- package/dist/_commonjsHelpers-DwGv2jUC.js +0 -1
package/dist/mock-sw.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const h=e=>{try{return new RegExp(e),!0}catch{return!1}},u=e=>{const s=e.split("?")[0];return/\.([a-zA-Z0-9]+)$/.test(s)};function f(e,s,n){return n.find(t=>{const o=t.method.toLowerCase()===e.toLowerCase();if(t.urlRegex&&h(t.url)){const a=new RegExp(t.url);return o&&a.test(s)}if(u(t.url))return o&&s.includes(t.url);const l=t.url===s||s.includes(t.url);return o&&l&&!u(s)})}function p(e,s,n){e.forEach(t=>t.postMessage({type:"EXECUTED",alias:s.alias,request:n}))}const y=(e,s,n)=>{const o=![204,205,304].includes(s),i=o?JSON.stringify(e):null;return new Response(i,{status:s,headers:o?n||{"Content-Type":"application/json"}:n||{}})},c="1.2.
|
|
1
|
+
const h=e=>{try{return new RegExp(e),!0}catch{return!1}},u=e=>{const s=e.split("?")[0];return/\.([a-zA-Z0-9]+)$/.test(s)};function f(e,s,n){return n.find(t=>{const o=t.method.toLowerCase()===e.toLowerCase();if(t.urlRegex&&h(t.url)){const a=new RegExp(t.url);return o&&a.test(s)}if(u(t.url))return o&&s.includes(t.url);const l=t.url===s||s.includes(t.url);return o&&l&&!u(s)})}function p(e,s,n){e.forEach(t=>t.postMessage({type:"EXECUTED",alias:s.alias,request:n}))}const y=(e,s,n)=>{const o=![204,205,304].includes(s),i=o?JSON.stringify(e):null;return new Response(i,{status:s,headers:o?n||{"Content-Type":"application/json"}:n||{}})},c="1.2.3";let r=[];const g=async e=>{const{method:s}=e.request,n=e.request.url,t=f(s,n,r);t&&(console.log("[TWD] Mock hit:",t.alias,s,n),e.respondWith((async()=>{let o=null;const i=e.request.headers.get("content-type")||"application/json";if(i.includes("application/json"))try{o=await e.request.clone().json()}catch{}else if(i.includes("form"))try{const l=await e.request.clone().formData();o={},l.forEach((a,d)=>{o[d]=a})}catch{}else if(i.includes("text"))try{o=await e.request.clone().text()}catch{}else if(i.includes("octet-stream"))try{o=await e.request.clone().arrayBuffer()}catch{}else if(i.includes("image"))try{o=await e.request.clone().blob()}catch{}else try{o=await e.request.clone().text()}catch{}return self.clients.matchAll().then(l=>{p(l,t,o)}),y(t.response,t.status??200,t.responseHeaders)})()))},m=e=>{e!==c&&console.warn(`[TWD] ⚠️ Version mismatch detected:
|
|
2
2
|
Client version: ${e}
|
|
3
3
|
Service Worker version: ${c}
|
|
4
4
|
|
package/dist/runner-ci.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i="\x1B[0m",x="\x1B[32m",$="\x1B[31m",y="\x1B[33m",E=(e,t)=>{const f=[...e].filter(s=>!s.parent),o=(s,n=0)=>{const c=" ".repeat(n),u=t.find(l=>l.id===s.id);let r="",a="";s.type!=="suite"&&(u?.status==="pass"?r=`${x}✓${i}`:u?.status==="fail"?(r=`${$}✗${i}`,a=` - Error: ${u.error}`):r=`${y}○${i}`);const d=s.type==="suite"?`${c}${s.name}`:`${c}${r} ${s.name}`;if(console.log(d),a&&console.log(`${$}${c}${a}${i}`),s.children)for(const l of s.children){const p=e.find(m=>m.id===l);p&&o(p,n+1)}};for(const s of f)o(s)},R=async()=>{const e=window.__testRunner,t=[],o=await new e({onStart:()=>{},onPass:s=>{t.push({id:s.id,status:"pass"})},onFail:(s,n)=>{t.push({id:s.id,status:"fail",error:n.message})},onSkip:s=>{t.push({id:s.id,status:"skip"})}}).runAll();return{handlers:Array.from(o.values()),testStatus:t}};exports.executeTests=R;exports.reportResults=E;
|
package/dist/runner-ci.es.js
CHANGED
|
@@ -1,44 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var y = /* @__PURE__ */ w();
|
|
12
|
-
const a = /* @__PURE__ */ B(y), m = (r, t) => {
|
|
13
|
-
const p = [...r].filter((e) => !e.parent), o = (e, s = 0) => {
|
|
14
|
-
const g = " ".repeat(s), l = t.find((u) => u.id === e.id);
|
|
15
|
-
let i = "", c = "";
|
|
16
|
-
e.type !== "suite" && (l?.status === "pass" ? i = a.green("✓") : l?.status === "fail" ? (i = a.red("✗"), c = ` - Error: ${l.error}`) : i = a.yellow("○"));
|
|
17
|
-
const d = e.type === "suite" ? `${g}${e.name}` : `${g}${i} ${e.name}`;
|
|
18
|
-
if (console.log(d), c && console.log(a.red(`${g}${c}`)), e.children)
|
|
19
|
-
for (const u of e.children) {
|
|
20
|
-
const b = r.find((f) => f.id === u);
|
|
21
|
-
b && o(b, s + 1);
|
|
1
|
+
const i = "\x1B[0m", x = "\x1B[32m", p = "\x1B[31m", E = "\x1B[33m", R = (o, t) => {
|
|
2
|
+
const f = [...o].filter((s) => !s.parent), n = (s, e = 0) => {
|
|
3
|
+
const c = " ".repeat(e), a = t.find((l) => l.id === s.id);
|
|
4
|
+
let r = "", u = "";
|
|
5
|
+
s.type !== "suite" && (a?.status === "pass" ? r = `${x}✓${i}` : a?.status === "fail" ? (r = `${p}✗${i}`, u = ` - Error: ${a.error}`) : r = `${E}○${i}`);
|
|
6
|
+
const d = s.type === "suite" ? `${c}${s.name}` : `${c}${r} ${s.name}`;
|
|
7
|
+
if (console.log(d), u && console.log(`${p}${c}${u}${i}`), s.children)
|
|
8
|
+
for (const l of s.children) {
|
|
9
|
+
const $ = o.find((m) => m.id === l);
|
|
10
|
+
$ && n($, e + 1);
|
|
22
11
|
}
|
|
23
12
|
};
|
|
24
|
-
for (const
|
|
25
|
-
},
|
|
26
|
-
const
|
|
13
|
+
for (const s of f) n(s);
|
|
14
|
+
}, y = async () => {
|
|
15
|
+
const o = window.__testRunner, t = [], n = await new o({
|
|
27
16
|
onStart: () => {
|
|
28
17
|
},
|
|
29
|
-
onPass: (
|
|
30
|
-
t.push({ id:
|
|
18
|
+
onPass: (s) => {
|
|
19
|
+
t.push({ id: s.id, status: "pass" });
|
|
31
20
|
},
|
|
32
|
-
onFail: (
|
|
33
|
-
t.push({ id:
|
|
21
|
+
onFail: (s, e) => {
|
|
22
|
+
t.push({ id: s.id, status: "fail", error: e.message });
|
|
34
23
|
},
|
|
35
|
-
onSkip: (
|
|
36
|
-
t.push({ id:
|
|
24
|
+
onSkip: (s) => {
|
|
25
|
+
t.push({ id: s.id, status: "skip" });
|
|
37
26
|
}
|
|
38
27
|
}).runAll();
|
|
39
|
-
return { handlers: Array.from(
|
|
28
|
+
return { handlers: Array.from(n.values()), testStatus: t };
|
|
40
29
|
};
|
|
41
30
|
export {
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
y as executeTests,
|
|
32
|
+
R as reportResults
|
|
44
33
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twd-js",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Test While Developing (TWD) - in-browser testing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "BRIKEV",
|
|
@@ -70,17 +70,17 @@
|
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@testing-library/jest-dom": "^6.9.1",
|
|
72
72
|
"@testing-library/react": "^16.3.0",
|
|
73
|
-
"@types/react": "^19.2.
|
|
73
|
+
"@types/react": "^19.2.7",
|
|
74
74
|
"@types/react-dom": "^19.2.3",
|
|
75
75
|
"@vitejs/plugin-react": "^5.1.1",
|
|
76
|
-
"@vitest/coverage-v8": "^4.0.
|
|
76
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
77
77
|
"conventional-changelog": "^7.1.1",
|
|
78
78
|
"jsdom": "^27.2.0",
|
|
79
79
|
"typescript": "^5.9.3",
|
|
80
|
-
"vite": "^7.2.
|
|
80
|
+
"vite": "^7.2.6",
|
|
81
81
|
"vite-plugin-dts": "^4.5.4",
|
|
82
82
|
"vitepress": "^2.0.0-alpha.12",
|
|
83
|
-
"vitest": "^4.0.
|
|
83
|
+
"vitest": "^4.0.15"
|
|
84
84
|
},
|
|
85
85
|
"keywords": [
|
|
86
86
|
"testing",
|
|
@@ -96,7 +96,6 @@
|
|
|
96
96
|
"@testing-library/dom": "^10.4.1",
|
|
97
97
|
"@testing-library/user-event": "^14.6.1",
|
|
98
98
|
"@types/chai": "^5.2.3",
|
|
99
|
-
"chai": "^6.2.1"
|
|
100
|
-
"picocolors": "^1.1.1"
|
|
99
|
+
"chai": "^6.2.1"
|
|
101
100
|
}
|
|
102
101
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}exports.getDefaultExportFromCjs=e;
|