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/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.2";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:
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
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("./_commonjsHelpers-DwGv2jUC.js");var n={exports:{}},d;function w(){if(d)return n.exports;d=1;var e=String,t=function(){return{isColorSupported:!1,reset:e,bold:e,dim:e,italic:e,underline:e,inverse:e,hidden:e,strikethrough:e,black:e,red:e,green:e,yellow:e,blue:e,magenta:e,cyan:e,white:e,gray:e,bgBlack:e,bgRed:e,bgGreen:e,bgYellow:e,bgBlue:e,bgMagenta:e,bgCyan:e,bgWhite:e,blackBright:e,redBright:e,greenBright:e,yellowBright:e,blueBright:e,magentaBright:e,cyanBright:e,whiteBright:e,bgBlackBright:e,bgRedBright:e,bgGreenBright:e,bgYellowBright:e,bgBlueBright:e,bgMagentaBright:e,bgCyanBright:e,bgWhiteBright:e}};return n.exports=t(),n.exports.createColors=t,n.exports}var y=w();const l=B.getDefaultExportFromCjs(y),m=(e,t)=>{const p=[...e].filter(r=>!r.parent),o=(r,s=0)=>{const a=" ".repeat(s),c=t.find(u=>u.id===r.id);let i="",g="";r.type!=="suite"&&(c?.status==="pass"?i=l.green("✓"):c?.status==="fail"?(i=l.red("✗"),g=` - Error: ${c.error}`):i=l.yellow("○"));const h=r.type==="suite"?`${a}${r.name}`:`${a}${i} ${r.name}`;if(console.log(h),g&&console.log(l.red(`${a}${g}`)),r.children)for(const u of r.children){const b=e.find(f=>f.id===u);b&&o(b,s+1)}};for(const r of p)o(r)},x=async()=>{const e=window.__testRunner,t=[],o=await new e({onStart:()=>{},onPass:r=>{t.push({id:r.id,status:"pass"})},onFail:(r,s)=>{t.push({id:r.id,status:"fail",error:s.message})},onSkip:r=>{t.push({id:r.id,status:"skip"})}}).runAll();return{handlers:Array.from(o.values()),testStatus:t}};exports.executeTests=x;exports.reportResults=m;
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;
@@ -1,44 +1,33 @@
1
- import { g as B } from "./_commonjsHelpers-C6fGbg64.mjs";
2
- var n = { exports: {} }, h;
3
- function w() {
4
- if (h) return n.exports;
5
- h = 1;
6
- var r = String, t = function() {
7
- return { isColorSupported: !1, reset: r, bold: r, dim: r, italic: r, underline: r, inverse: r, hidden: r, strikethrough: r, black: r, red: r, green: r, yellow: r, blue: r, magenta: r, cyan: r, white: r, gray: r, bgBlack: r, bgRed: r, bgGreen: r, bgYellow: r, bgBlue: r, bgMagenta: r, bgCyan: r, bgWhite: r, blackBright: r, redBright: r, greenBright: r, yellowBright: r, blueBright: r, magentaBright: r, cyanBright: r, whiteBright: r, bgBlackBright: r, bgRedBright: r, bgGreenBright: r, bgYellowBright: r, bgBlueBright: r, bgMagentaBright: r, bgCyanBright: r, bgWhiteBright: r };
8
- };
9
- return n.exports = t(), n.exports.createColors = t, n.exports;
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 e of p) o(e);
25
- }, $ = async () => {
26
- const r = window.__testRunner, t = [], o = await new r({
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: (e) => {
30
- t.push({ id: e.id, status: "pass" });
18
+ onPass: (s) => {
19
+ t.push({ id: s.id, status: "pass" });
31
20
  },
32
- onFail: (e, s) => {
33
- t.push({ id: e.id, status: "fail", error: s.message });
21
+ onFail: (s, e) => {
22
+ t.push({ id: s.id, status: "fail", error: e.message });
34
23
  },
35
- onSkip: (e) => {
36
- t.push({ id: e.id, status: "skip" });
24
+ onSkip: (s) => {
25
+ t.push({ id: s.id, status: "skip" });
37
26
  }
38
27
  }).runAll();
39
- return { handlers: Array.from(o.values()), testStatus: t };
28
+ return { handlers: Array.from(n.values()), testStatus: t };
40
29
  };
41
30
  export {
42
- $ as executeTests,
43
- m as reportResults
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.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.6",
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.13",
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.4",
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.13"
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,6 +0,0 @@
1
- function e(t) {
2
- return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
3
- }
4
- export {
5
- e as g
6
- };
@@ -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;