twd-js 0.7.0 → 0.7.1
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 +1 -1
- package/dist/runner-ci.cjs.js +1 -5
- package/dist/runner-ci.es.js +23 -293
- package/package.json +8 -8
package/dist/mock-sw.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const u=e=>{try{return new RegExp(e),!0}catch{return!1}};function d(e,s,n){return n.find(t=>{const o=t.method.toLowerCase()===e.toLowerCase();if(t.urlRegex&&u(t.url)){const a=new RegExp(t.url);return o&&a.test(s)}const l=t.url===s||s.includes(t.url);return o&&l})}function f(e,s,n){e.forEach(t=>t.postMessage({type:"EXECUTED",alias:s.alias,request:n}))}const h=(e,s,n)=>{const o=![204,205,304].includes(s),l=o?JSON.stringify(e):null;return new Response(l,{status:s,headers:o?n||{"Content-Type":"application/json"}:n||{}})};let c=[];const y=async e=>{const{method:s}=e.request,n=e.request.url,t=d(s,n,c);t&&(console.log("[TWD] Mock hit:",t.alias,s,n),e.respondWith((async()=>{let o=null;const l=e.request.headers.get("content-type")||"application/json";if(l.includes("application/json"))try{o=await e.request.clone().json()}catch{}else if(l.includes("form"))try{const a=await e.request.clone().formData();o={},a.forEach((r,i)=>{o[i]=r})}catch{}else if(l.includes("text"))try{o=await e.request.clone().text()}catch{}else if(l.includes("octet-stream"))try{o=await e.request.clone().arrayBuffer()}catch{}else if(l.includes("image"))try{o=await e.request.clone().blob()}catch{}else try{o=await e.request.clone().text()}catch{}return self.clients.matchAll().then(a=>{f(a,t,o)}),h(t.response,t.status??200,t.responseHeaders)})()))},p=e=>{const{type:s,rule:n}=e.data||{};s==="ADD_RULE"&&(c=c.filter(t=>t.alias!==n.alias),c.push(n),console.log("[TWD] Rule added:",n)),s==="CLEAR_RULES"&&(c=[],console.log("[TWD] All rules cleared"))};console.log("[TWD] Mock Service Worker loaded - version 0.7.
|
|
1
|
+
const u=e=>{try{return new RegExp(e),!0}catch{return!1}};function d(e,s,n){return n.find(t=>{const o=t.method.toLowerCase()===e.toLowerCase();if(t.urlRegex&&u(t.url)){const a=new RegExp(t.url);return o&&a.test(s)}const l=t.url===s||s.includes(t.url);return o&&l})}function f(e,s,n){e.forEach(t=>t.postMessage({type:"EXECUTED",alias:s.alias,request:n}))}const h=(e,s,n)=>{const o=![204,205,304].includes(s),l=o?JSON.stringify(e):null;return new Response(l,{status:s,headers:o?n||{"Content-Type":"application/json"}:n||{}})};let c=[];const y=async e=>{const{method:s}=e.request,n=e.request.url,t=d(s,n,c);t&&(console.log("[TWD] Mock hit:",t.alias,s,n),e.respondWith((async()=>{let o=null;const l=e.request.headers.get("content-type")||"application/json";if(l.includes("application/json"))try{o=await e.request.clone().json()}catch{}else if(l.includes("form"))try{const a=await e.request.clone().formData();o={},a.forEach((r,i)=>{o[i]=r})}catch{}else if(l.includes("text"))try{o=await e.request.clone().text()}catch{}else if(l.includes("octet-stream"))try{o=await e.request.clone().arrayBuffer()}catch{}else if(l.includes("image"))try{o=await e.request.clone().blob()}catch{}else try{o=await e.request.clone().text()}catch{}return self.clients.matchAll().then(a=>{f(a,t,o)}),h(t.response,t.status??200,t.responseHeaders)})()))},p=e=>{const{type:s,rule:n}=e.data||{};s==="ADD_RULE"&&(c=c.filter(t=>t.alias!==n.alias),c.push(n),console.log("[TWD] Rule added:",n)),s==="CLEAR_RULES"&&(c=[],console.log("[TWD] All rules cleared"))};console.log("[TWD] Mock Service Worker loaded - version 0.7.1");self.addEventListener("fetch",y);self.addEventListener("message",p);
|
package/dist/runner-ci.cjs.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`:`
|
|
3
|
-
`)+o,n=t+1,t=r.indexOf(`
|
|
4
|
-
`,n)}while(t!==-1);return s+=r.slice(n),s}const{stdout:x,stderr:R}=I,A=Symbol("GENERATOR"),u=Symbol("STYLER"),f=Symbol("IS_EMPTY"),$=["ansi","ansi","ansi256","ansi16m"],b=Object.create(null),L=(r,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const o=x?x.level:0;r.level=e.level===void 0?o:e.level},D=r=>{const e=(...o)=>o.join(" ");return L(e,r),Object.setPrototypeOf(e,h.prototype),e};function h(r){return D(r)}Object.setPrototypeOf(h.prototype,Function.prototype);for(const[r,e]of Object.entries(a))b[r]={get(){const o=p(this,O(e.open,e.close,this[u]),this[f]);return Object.defineProperty(this,r,{value:o}),o}};b.visible={get(){const r=p(this,this[u],!0);return Object.defineProperty(this,"visible",{value:r}),r}};const B=(r,e,o,...t)=>r==="rgb"?e==="ansi16m"?a[o].ansi16m(...t):e==="ansi256"?a[o].ansi256(a.rgbToAnsi256(...t)):a[o].ansi(a.rgbToAnsi(...t)):r==="hex"?B("rgb",e,o,...a.hexToRgb(...t)):a[o][r](...t),W=["rgb","hex","ansi256"];for(const r of W){b[r]={get(){const{level:o}=this;return function(...t){const n=O(B(r,$[o],"color",...t),a.color.close,this[u]);return p(this,n,this[f])}}};const e="bg"+r[0].toUpperCase()+r.slice(1);b[e]={get(){const{level:o}=this;return function(...t){const n=O(B(r,$[o],"bgColor",...t),a.bgColor.close,this[u]);return p(this,n,this[f])}}}}const U=Object.defineProperties(()=>{},{...b,level:{enumerable:!0,get(){return this[A].level},set(r){this[A].level=r}}}),O=(r,e,o)=>{let t,n;return o===void 0?(t=r,n=e):(t=o.openAll+r,n=e+o.closeAll),{open:r,close:e,openAll:t,closeAll:n,parent:o}},p=(r,e,o)=>{const t=(...n)=>V(t,n.length===1?""+n[0]:n.join(" "));return Object.setPrototypeOf(t,U),t[A]=r,t[u]=e,t[f]=o,t},V=(r,e)=>{if(r.level<=0||!e)return r[f]?"":e;let o=r[u];if(o===void 0)return e;const{openAll:t,closeAll:n}=o;if(e.includes("\x1B"))for(;o!==void 0;)e=G(e,o.close,o.open),o=o.parent;const s=e.indexOf(`
|
|
5
|
-
`);return s!==-1&&(e=Y(e,n,t,s)),t+e+n};Object.defineProperties(h.prototype,b);const d=h();h({level:R?R.level:0});const H=(r,e)=>{const o=[...r].filter(n=>!n.parent),t=(n,s=0)=>{const i=" ".repeat(s),c=e.find(m=>m.id===n.id);let g="",y="";n.type!=="suite"&&(c?.status==="pass"?g=d.green("✓"):c?.status==="fail"?(g=d.red("✗"),y=` - Error: ${c.error}`):g=d.yellow("○"));const k=n.type==="suite"?`${i}${n.name}`:`${i}${g} ${n.name}`;if(console.log(k),y&&console.log(d.red(`${i}${y}`)),n.children)for(const m of n.children){const T=r.find(P=>P.id===m);T&&t(T,s+1)}};for(const n of o)t(n)},K=async()=>{const r=window.__testRunner,e=[],t=await new r({onStart:()=>{},onPass:n=>{e.push({id:n.id,status:"pass"})},onFail:(n,s)=>{e.push({id:n.id,status:"fail",error:s.message})},onSkip:n=>{e.push({id:n.id,status:"skip"})}}).runAll();return{handlers:Array.from(t.values()),testStatus:e}};exports.executeTests=K;exports.reportResults=H;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("chalk"),$=(e,t)=>{const f=[...e].filter(s=>!s.parent),o=(s,r=0)=>{const c=" ".repeat(r),u=t.find(a=>a.id===s.id);let n="",l="";s.type!=="suite"&&(u?.status==="pass"?n=i.green("✓"):u?.status==="fail"?(n=i.red("✗"),l=` - Error: ${u.error}`):n=i.yellow("○"));const p=s.type==="suite"?`${c}${s.name}`:`${c}${n} ${s.name}`;if(console.log(p),l&&console.log(i.red(`${c}${l}`)),s.children)for(const a of s.children){const d=e.find(y=>y.id===a);d&&o(d,r+1)}};for(const s of f)o(s)},g=async()=>{const e=window.__testRunner,t=[],o=await new e({onStart:()=>{},onPass:s=>{t.push({id:s.id,status:"pass"})},onFail:(s,r)=>{t.push({id:s.id,status:"fail",error:r.message})},onSkip:s=>{t.push({id:s.id,status:"skip"})}}).runAll();return{handlers:Array.from(o.values()),testStatus:t}};exports.executeTests=g;exports.reportResults=$;
|
package/dist/runner-ci.es.js
CHANGED
|
@@ -1,304 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
strikethrough: [9, 29]
|
|
13
|
-
},
|
|
14
|
-
color: {
|
|
15
|
-
black: [30, 39],
|
|
16
|
-
red: [31, 39],
|
|
17
|
-
green: [32, 39],
|
|
18
|
-
yellow: [33, 39],
|
|
19
|
-
blue: [34, 39],
|
|
20
|
-
magenta: [35, 39],
|
|
21
|
-
cyan: [36, 39],
|
|
22
|
-
white: [37, 39],
|
|
23
|
-
// Bright color
|
|
24
|
-
blackBright: [90, 39],
|
|
25
|
-
gray: [90, 39],
|
|
26
|
-
// Alias of `blackBright`
|
|
27
|
-
grey: [90, 39],
|
|
28
|
-
// Alias of `blackBright`
|
|
29
|
-
redBright: [91, 39],
|
|
30
|
-
greenBright: [92, 39],
|
|
31
|
-
yellowBright: [93, 39],
|
|
32
|
-
blueBright: [94, 39],
|
|
33
|
-
magentaBright: [95, 39],
|
|
34
|
-
cyanBright: [96, 39],
|
|
35
|
-
whiteBright: [97, 39]
|
|
36
|
-
},
|
|
37
|
-
bgColor: {
|
|
38
|
-
bgBlack: [40, 49],
|
|
39
|
-
bgRed: [41, 49],
|
|
40
|
-
bgGreen: [42, 49],
|
|
41
|
-
bgYellow: [43, 49],
|
|
42
|
-
bgBlue: [44, 49],
|
|
43
|
-
bgMagenta: [45, 49],
|
|
44
|
-
bgCyan: [46, 49],
|
|
45
|
-
bgWhite: [47, 49],
|
|
46
|
-
// Bright color
|
|
47
|
-
bgBlackBright: [100, 49],
|
|
48
|
-
bgGray: [100, 49],
|
|
49
|
-
// Alias of `bgBlackBright`
|
|
50
|
-
bgGrey: [100, 49],
|
|
51
|
-
// Alias of `bgBlackBright`
|
|
52
|
-
bgRedBright: [101, 49],
|
|
53
|
-
bgGreenBright: [102, 49],
|
|
54
|
-
bgYellowBright: [103, 49],
|
|
55
|
-
bgBlueBright: [104, 49],
|
|
56
|
-
bgMagentaBright: [105, 49],
|
|
57
|
-
bgCyanBright: [106, 49],
|
|
58
|
-
bgWhiteBright: [107, 49]
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
Object.keys(l.modifier);
|
|
62
|
-
const N = Object.keys(l.color), k = Object.keys(l.bgColor);
|
|
63
|
-
[...N, ...k];
|
|
64
|
-
function E() {
|
|
65
|
-
const r = /* @__PURE__ */ new Map();
|
|
66
|
-
for (const [e, o] of Object.entries(l)) {
|
|
67
|
-
for (const [t, n] of Object.entries(o))
|
|
68
|
-
l[t] = {
|
|
69
|
-
open: `\x1B[${n[0]}m`,
|
|
70
|
-
close: `\x1B[${n[1]}m`
|
|
71
|
-
}, o[t] = l[t], r.set(n[0], n[1]);
|
|
72
|
-
Object.defineProperty(l, e, {
|
|
73
|
-
value: o,
|
|
74
|
-
enumerable: !1
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
return Object.defineProperty(l, "codes", {
|
|
78
|
-
value: r,
|
|
79
|
-
enumerable: !1
|
|
80
|
-
}), l.color.close = "\x1B[39m", l.bgColor.close = "\x1B[49m", l.color.ansi = T(), l.color.ansi256 = C(), l.color.ansi16m = S(), l.bgColor.ansi = T(10), l.bgColor.ansi256 = C(10), l.bgColor.ansi16m = S(10), Object.defineProperties(l, {
|
|
81
|
-
rgbToAnsi256: {
|
|
82
|
-
value(e, o, t) {
|
|
83
|
-
return e === o && o === t ? e < 8 ? 16 : e > 248 ? 231 : Math.round((e - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(e / 255 * 5) + 6 * Math.round(o / 255 * 5) + Math.round(t / 255 * 5);
|
|
84
|
-
},
|
|
85
|
-
enumerable: !1
|
|
86
|
-
},
|
|
87
|
-
hexToRgb: {
|
|
88
|
-
value(e) {
|
|
89
|
-
const o = /[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));
|
|
90
|
-
if (!o)
|
|
91
|
-
return [0, 0, 0];
|
|
92
|
-
let [t] = o;
|
|
93
|
-
t.length === 3 && (t = [...t].map((s) => s + s).join(""));
|
|
94
|
-
const n = Number.parseInt(t, 16);
|
|
95
|
-
return [
|
|
96
|
-
/* eslint-disable no-bitwise */
|
|
97
|
-
n >> 16 & 255,
|
|
98
|
-
n >> 8 & 255,
|
|
99
|
-
n & 255
|
|
100
|
-
/* eslint-enable no-bitwise */
|
|
101
|
-
];
|
|
102
|
-
},
|
|
103
|
-
enumerable: !1
|
|
104
|
-
},
|
|
105
|
-
hexToAnsi256: {
|
|
106
|
-
value: (e) => l.rgbToAnsi256(...l.hexToRgb(e)),
|
|
107
|
-
enumerable: !1
|
|
108
|
-
},
|
|
109
|
-
ansi256ToAnsi: {
|
|
110
|
-
value(e) {
|
|
111
|
-
if (e < 8)
|
|
112
|
-
return 30 + e;
|
|
113
|
-
if (e < 16)
|
|
114
|
-
return 90 + (e - 8);
|
|
115
|
-
let o, t, n;
|
|
116
|
-
if (e >= 232)
|
|
117
|
-
o = ((e - 232) * 10 + 8) / 255, t = o, n = o;
|
|
118
|
-
else {
|
|
119
|
-
e -= 16;
|
|
120
|
-
const c = e % 36;
|
|
121
|
-
o = Math.floor(e / 36) / 5, t = Math.floor(c / 6) / 5, n = c % 6 / 5;
|
|
122
|
-
}
|
|
123
|
-
const s = Math.max(o, t, n) * 2;
|
|
124
|
-
if (s === 0)
|
|
125
|
-
return 30;
|
|
126
|
-
let i = 30 + (Math.round(n) << 2 | Math.round(t) << 1 | Math.round(o));
|
|
127
|
-
return s === 2 && (i += 60), i;
|
|
128
|
-
},
|
|
129
|
-
enumerable: !1
|
|
130
|
-
},
|
|
131
|
-
rgbToAnsi: {
|
|
132
|
-
value: (e, o, t) => l.ansi256ToAnsi(l.rgbToAnsi256(e, o, t)),
|
|
133
|
-
enumerable: !1
|
|
134
|
-
},
|
|
135
|
-
hexToAnsi: {
|
|
136
|
-
value: (e) => l.ansi256ToAnsi(l.hexToAnsi256(e)),
|
|
137
|
-
enumerable: !1
|
|
138
|
-
}
|
|
139
|
-
}), l;
|
|
140
|
-
}
|
|
141
|
-
const a = E(), R = (() => {
|
|
142
|
-
if (!("navigator" in globalThis))
|
|
143
|
-
return 0;
|
|
144
|
-
if (globalThis.navigator.userAgentData) {
|
|
145
|
-
const r = navigator.userAgentData.brands.find(({ brand: e }) => e === "Chromium");
|
|
146
|
-
if (r && r.version > 93)
|
|
147
|
-
return 3;
|
|
148
|
-
}
|
|
149
|
-
return /\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent) ? 1 : 0;
|
|
150
|
-
})(), j = R !== 0 && {
|
|
151
|
-
level: R
|
|
152
|
-
}, I = {
|
|
153
|
-
stdout: j,
|
|
154
|
-
stderr: j
|
|
155
|
-
};
|
|
156
|
-
function P(r, e, o) {
|
|
157
|
-
let t = r.indexOf(e);
|
|
158
|
-
if (t === -1)
|
|
159
|
-
return r;
|
|
160
|
-
const n = e.length;
|
|
161
|
-
let s = 0, i = "";
|
|
162
|
-
do
|
|
163
|
-
i += r.slice(s, t) + e + o, s = t + n, t = r.indexOf(e, s);
|
|
164
|
-
while (t !== -1);
|
|
165
|
-
return i += r.slice(s), i;
|
|
166
|
-
}
|
|
167
|
-
function G(r, e, o, t) {
|
|
168
|
-
let n = 0, s = "";
|
|
169
|
-
do {
|
|
170
|
-
const i = r[t - 1] === "\r";
|
|
171
|
-
s += r.slice(n, i ? t - 1 : t) + e + (i ? `\r
|
|
172
|
-
` : `
|
|
173
|
-
`) + o, n = t + 1, t = r.indexOf(`
|
|
174
|
-
`, n);
|
|
175
|
-
} while (t !== -1);
|
|
176
|
-
return s += r.slice(n), s;
|
|
177
|
-
}
|
|
178
|
-
const { stdout: w, stderr: x } = I, v = Symbol("GENERATOR"), u = Symbol("STYLER"), b = Symbol("IS_EMPTY"), M = [
|
|
179
|
-
"ansi",
|
|
180
|
-
"ansi",
|
|
181
|
-
"ansi256",
|
|
182
|
-
"ansi16m"
|
|
183
|
-
], f = /* @__PURE__ */ Object.create(null), D = (r, e = {}) => {
|
|
184
|
-
if (e.level && !(Number.isInteger(e.level) && e.level >= 0 && e.level <= 3))
|
|
185
|
-
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
186
|
-
const o = w ? w.level : 0;
|
|
187
|
-
r.level = e.level === void 0 ? o : e.level;
|
|
188
|
-
}, Y = (r) => {
|
|
189
|
-
const e = (...o) => o.join(" ");
|
|
190
|
-
return D(e, r), Object.setPrototypeOf(e, h.prototype), e;
|
|
191
|
-
};
|
|
192
|
-
function h(r) {
|
|
193
|
-
return Y(r);
|
|
194
|
-
}
|
|
195
|
-
Object.setPrototypeOf(h.prototype, Function.prototype);
|
|
196
|
-
for (const [r, e] of Object.entries(a))
|
|
197
|
-
f[r] = {
|
|
198
|
-
get() {
|
|
199
|
-
const o = p(this, O(e.open, e.close, this[u]), this[b]);
|
|
200
|
-
return Object.defineProperty(this, r, { value: o }), o;
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
f.visible = {
|
|
204
|
-
get() {
|
|
205
|
-
const r = p(this, this[u], !0);
|
|
206
|
-
return Object.defineProperty(this, "visible", { value: r }), r;
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
const A = (r, e, o, ...t) => r === "rgb" ? e === "ansi16m" ? a[o].ansi16m(...t) : e === "ansi256" ? a[o].ansi256(a.rgbToAnsi256(...t)) : a[o].ansi(a.rgbToAnsi(...t)) : r === "hex" ? A("rgb", e, o, ...a.hexToRgb(...t)) : a[o][r](...t), _ = ["rgb", "hex", "ansi256"];
|
|
210
|
-
for (const r of _) {
|
|
211
|
-
f[r] = {
|
|
212
|
-
get() {
|
|
213
|
-
const { level: o } = this;
|
|
214
|
-
return function(...t) {
|
|
215
|
-
const n = O(A(r, M[o], "color", ...t), a.color.close, this[u]);
|
|
216
|
-
return p(this, n, this[b]);
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
const e = "bg" + r[0].toUpperCase() + r.slice(1);
|
|
221
|
-
f[e] = {
|
|
222
|
-
get() {
|
|
223
|
-
const { level: o } = this;
|
|
224
|
-
return function(...t) {
|
|
225
|
-
const n = O(A(r, M[o], "bgColor", ...t), a.bgColor.close, this[u]);
|
|
226
|
-
return p(this, n, this[b]);
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
const L = Object.defineProperties(() => {
|
|
232
|
-
}, {
|
|
233
|
-
...f,
|
|
234
|
-
level: {
|
|
235
|
-
enumerable: !0,
|
|
236
|
-
get() {
|
|
237
|
-
return this[v].level;
|
|
238
|
-
},
|
|
239
|
-
set(r) {
|
|
240
|
-
this[v].level = r;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}), O = (r, e, o) => {
|
|
244
|
-
let t, n;
|
|
245
|
-
return o === void 0 ? (t = r, n = e) : (t = o.openAll + r, n = e + o.closeAll), {
|
|
246
|
-
open: r,
|
|
247
|
-
close: e,
|
|
248
|
-
openAll: t,
|
|
249
|
-
closeAll: n,
|
|
250
|
-
parent: o
|
|
251
|
-
};
|
|
252
|
-
}, p = (r, e, o) => {
|
|
253
|
-
const t = (...n) => U(t, n.length === 1 ? "" + n[0] : n.join(" "));
|
|
254
|
-
return Object.setPrototypeOf(t, L), t[v] = r, t[u] = e, t[b] = o, t;
|
|
255
|
-
}, U = (r, e) => {
|
|
256
|
-
if (r.level <= 0 || !e)
|
|
257
|
-
return r[b] ? "" : e;
|
|
258
|
-
let o = r[u];
|
|
259
|
-
if (o === void 0)
|
|
260
|
-
return e;
|
|
261
|
-
const { openAll: t, closeAll: n } = o;
|
|
262
|
-
if (e.includes("\x1B"))
|
|
263
|
-
for (; o !== void 0; )
|
|
264
|
-
e = P(e, o.close, o.open), o = o.parent;
|
|
265
|
-
const s = e.indexOf(`
|
|
266
|
-
`);
|
|
267
|
-
return s !== -1 && (e = G(e, n, t, s)), t + e + n;
|
|
268
|
-
};
|
|
269
|
-
Object.defineProperties(h.prototype, f);
|
|
270
|
-
const d = h();
|
|
271
|
-
h({ level: x ? x.level : 0 });
|
|
272
|
-
const K = (r, e) => {
|
|
273
|
-
const o = [...r].filter((n) => !n.parent), t = (n, s = 0) => {
|
|
274
|
-
const i = " ".repeat(s), c = e.find((y) => y.id === n.id);
|
|
275
|
-
let g = "", m = "";
|
|
276
|
-
n.type !== "suite" && (c?.status === "pass" ? g = d.green("✓") : c?.status === "fail" ? (g = d.red("✗"), m = ` - Error: ${c.error}`) : g = d.yellow("○"));
|
|
277
|
-
const F = n.type === "suite" ? `${i}${n.name}` : `${i}${g} ${n.name}`;
|
|
278
|
-
if (console.log(F), m && console.log(d.red(`${i}${m}`)), n.children)
|
|
279
|
-
for (const y of n.children) {
|
|
280
|
-
const B = r.find(($) => $.id === y);
|
|
281
|
-
B && t(B, s + 1);
|
|
1
|
+
import i from "chalk";
|
|
2
|
+
const y = (e, t) => {
|
|
3
|
+
const f = [...e].filter((s) => !s.parent), o = (s, r = 0) => {
|
|
4
|
+
const c = " ".repeat(r), a = t.find((u) => u.id === s.id);
|
|
5
|
+
let n = "", l = "";
|
|
6
|
+
s.type !== "suite" && (a?.status === "pass" ? n = i.green("✓") : a?.status === "fail" ? (n = i.red("✗"), l = ` - Error: ${a.error}`) : n = i.yellow("○"));
|
|
7
|
+
const d = s.type === "suite" ? `${c}${s.name}` : `${c}${n} ${s.name}`;
|
|
8
|
+
if (console.log(d), l && console.log(i.red(`${c}${l}`)), s.children)
|
|
9
|
+
for (const u of s.children) {
|
|
10
|
+
const p = e.find(($) => $.id === u);
|
|
11
|
+
p && o(p, r + 1);
|
|
282
12
|
}
|
|
283
13
|
};
|
|
284
|
-
for (const
|
|
285
|
-
},
|
|
286
|
-
const
|
|
14
|
+
for (const s of f) o(s);
|
|
15
|
+
}, g = async () => {
|
|
16
|
+
const e = window.__testRunner, t = [], o = await new e({
|
|
287
17
|
onStart: () => {
|
|
288
18
|
},
|
|
289
|
-
onPass: (
|
|
290
|
-
|
|
19
|
+
onPass: (s) => {
|
|
20
|
+
t.push({ id: s.id, status: "pass" });
|
|
291
21
|
},
|
|
292
|
-
onFail: (
|
|
293
|
-
|
|
22
|
+
onFail: (s, r) => {
|
|
23
|
+
t.push({ id: s.id, status: "fail", error: r.message });
|
|
294
24
|
},
|
|
295
|
-
onSkip: (
|
|
296
|
-
|
|
25
|
+
onSkip: (s) => {
|
|
26
|
+
t.push({ id: s.id, status: "skip" });
|
|
297
27
|
}
|
|
298
28
|
}).runAll();
|
|
299
|
-
return { handlers: Array.from(
|
|
29
|
+
return { handlers: Array.from(o.values()), testStatus: t };
|
|
300
30
|
};
|
|
301
31
|
export {
|
|
302
|
-
|
|
303
|
-
|
|
32
|
+
g as executeTests,
|
|
33
|
+
y as reportResults
|
|
304
34
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twd-js",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Test While Developing (TWD) - in-browser testing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "BRIKEV",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"bugs": {
|
|
9
9
|
"url": "https://github.com/BRIKEV/twd/issues"
|
|
10
10
|
},
|
|
11
|
-
"main": "./dist/
|
|
12
|
-
"module": "./dist/
|
|
11
|
+
"main": "./dist/index.cjs.js",
|
|
12
|
+
"module": "./dist/index.es.js",
|
|
13
13
|
"types": "./dist/index.d.ts",
|
|
14
14
|
"bin": {
|
|
15
15
|
"twd-js": "./dist/cli.js"
|
|
@@ -21,23 +21,23 @@
|
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
|
-
"import": "./dist/
|
|
25
|
-
"require": "./dist/
|
|
24
|
+
"import": "./dist/index.es.js",
|
|
25
|
+
"require": "./dist/index.cjs.js"
|
|
26
26
|
},
|
|
27
27
|
"./runner": {
|
|
28
28
|
"types": "./dist/runner.d.ts",
|
|
29
29
|
"import": "./dist/runner.es.js",
|
|
30
|
-
"require": "./dist/runner.
|
|
30
|
+
"require": "./dist/runner.cjs.js"
|
|
31
31
|
},
|
|
32
32
|
"./vite-plugin": {
|
|
33
33
|
"types": "./dist/vite-plugin.d.ts",
|
|
34
34
|
"import": "./dist/vite-plugin.es.js",
|
|
35
|
-
"require": "./dist/vite-plugin.
|
|
35
|
+
"require": "./dist/vite-plugin.cjs.js"
|
|
36
36
|
},
|
|
37
37
|
"./runner-ci": {
|
|
38
38
|
"types": "./dist/runner-ci.d.ts",
|
|
39
39
|
"import": "./dist/runner-ci.es.js",
|
|
40
|
-
"require": "./dist/runner-ci.
|
|
40
|
+
"require": "./dist/runner-ci.cjs.js"
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"files": [
|