twd-js 1.2.3 → 1.3.0-beta.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.
- package/dist/bundled.d.ts +9 -0
- package/dist/bundled.es.js +46257 -0
- package/dist/bundled.umd.js +311 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +2 -2
- package/dist/jsx-runtime-CjngqUuo.js +6 -0
- package/dist/{jsx-runtime-CtyxV31n.mjs → jsx-runtime-DqUUEvWR.mjs} +125 -127
- package/dist/mock-sw.js +2 -2
- package/dist/runner.cjs.js +1 -1
- package/dist/runner.es.js +43 -33
- package/dist/ui.cjs.js +1 -1
- package/dist/ui.es.js +1 -1
- package/package.json +9 -3
- package/dist/jsx-runtime-DN5DOl8k.js +0 -6
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
3
|
-
|
|
1
|
+
import ee from "react";
|
|
2
|
+
const P = /* @__PURE__ */ new Map(), oe = (o, l) => {
|
|
3
|
+
P.set(o, l);
|
|
4
4
|
};
|
|
5
|
-
function
|
|
6
|
-
|
|
5
|
+
function se() {
|
|
6
|
+
P.clear();
|
|
7
7
|
}
|
|
8
|
-
const ue = (
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
function
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
function
|
|
16
|
-
var
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
for (var
|
|
20
|
-
|
|
21
|
-
} else
|
|
22
|
-
return s =
|
|
23
|
-
$$typeof:
|
|
24
|
-
type:
|
|
25
|
-
key:
|
|
8
|
+
const ue = (o) => P.get(o);
|
|
9
|
+
var b = { exports: {} }, _ = {};
|
|
10
|
+
var F;
|
|
11
|
+
function re() {
|
|
12
|
+
if (F) return _;
|
|
13
|
+
F = 1;
|
|
14
|
+
var o = Symbol.for("react.transitional.element"), l = Symbol.for("react.fragment");
|
|
15
|
+
function i(f, s, u) {
|
|
16
|
+
var m = null;
|
|
17
|
+
if (u !== void 0 && (m = "" + u), s.key !== void 0 && (m = "" + s.key), "key" in s) {
|
|
18
|
+
u = {};
|
|
19
|
+
for (var d in s)
|
|
20
|
+
d !== "key" && (u[d] = s[d]);
|
|
21
|
+
} else u = s;
|
|
22
|
+
return s = u.ref, {
|
|
23
|
+
$$typeof: o,
|
|
24
|
+
type: f,
|
|
25
|
+
key: m,
|
|
26
26
|
ref: s !== void 0 ? s : null,
|
|
27
|
-
props:
|
|
27
|
+
props: u
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
return
|
|
30
|
+
return _.Fragment = l, _.jsx = i, _.jsxs = i, _;
|
|
31
31
|
}
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
function
|
|
35
|
-
return
|
|
36
|
-
function
|
|
32
|
+
var E = {};
|
|
33
|
+
var I;
|
|
34
|
+
function te() {
|
|
35
|
+
return I || (I = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
36
|
+
function o(e) {
|
|
37
37
|
if (e == null) return null;
|
|
38
38
|
if (typeof e == "function")
|
|
39
|
-
return e.$$typeof ===
|
|
39
|
+
return e.$$typeof === Z ? null : e.displayName || e.name || null;
|
|
40
40
|
if (typeof e == "string") return e;
|
|
41
41
|
switch (e) {
|
|
42
|
-
case
|
|
42
|
+
case v:
|
|
43
43
|
return "Fragment";
|
|
44
|
-
case J:
|
|
45
|
-
return "Profiler";
|
|
46
44
|
case q:
|
|
45
|
+
return "Profiler";
|
|
46
|
+
case U:
|
|
47
47
|
return "StrictMode";
|
|
48
|
-
case
|
|
48
|
+
case G:
|
|
49
49
|
return "Suspense";
|
|
50
|
-
case
|
|
50
|
+
case X:
|
|
51
51
|
return "SuspenseList";
|
|
52
|
-
case
|
|
52
|
+
case H:
|
|
53
53
|
return "Activity";
|
|
54
54
|
}
|
|
55
55
|
if (typeof e == "object")
|
|
56
56
|
switch (typeof e.tag == "number" && console.error(
|
|
57
57
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
58
58
|
), e.$$typeof) {
|
|
59
|
-
case
|
|
59
|
+
case W:
|
|
60
60
|
return "Portal";
|
|
61
61
|
case V:
|
|
62
|
-
return
|
|
63
|
-
case
|
|
62
|
+
return e.displayName || "Context";
|
|
63
|
+
case J:
|
|
64
64
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
65
|
-
case
|
|
65
|
+
case z:
|
|
66
66
|
var r = e.render;
|
|
67
67
|
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
68
|
-
case
|
|
69
|
-
return r = e.displayName || null, r !== null ? r :
|
|
70
|
-
case
|
|
68
|
+
case B:
|
|
69
|
+
return r = e.displayName || null, r !== null ? r : o(e.type) || "Memo";
|
|
70
|
+
case T:
|
|
71
71
|
r = e._payload, e = e._init;
|
|
72
72
|
try {
|
|
73
|
-
return
|
|
73
|
+
return o(e(r));
|
|
74
74
|
} catch {
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function l(e) {
|
|
80
80
|
return "" + e;
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function i(e) {
|
|
83
83
|
try {
|
|
84
|
-
|
|
84
|
+
l(e);
|
|
85
85
|
var r = !1;
|
|
86
86
|
} catch {
|
|
87
87
|
r = !0;
|
|
@@ -93,15 +93,15 @@ function ne() {
|
|
|
93
93
|
r,
|
|
94
94
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
95
95
|
n
|
|
96
|
-
),
|
|
96
|
+
), l(e);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
if (e ===
|
|
101
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
99
|
+
function f(e) {
|
|
100
|
+
if (e === v) return "<>";
|
|
101
|
+
if (typeof e == "object" && e !== null && e.$$typeof === T)
|
|
102
102
|
return "<...>";
|
|
103
103
|
try {
|
|
104
|
-
var r =
|
|
104
|
+
var r = o(e);
|
|
105
105
|
return r ? "<" + r + ">" : "<...>";
|
|
106
106
|
} catch {
|
|
107
107
|
return "<...>";
|
|
@@ -111,19 +111,19 @@ function ne() {
|
|
|
111
111
|
var e = k.A;
|
|
112
112
|
return e === null ? null : e.getOwner();
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function u() {
|
|
115
115
|
return Error("react-stack-top-frame");
|
|
116
116
|
}
|
|
117
|
-
function
|
|
118
|
-
if (
|
|
117
|
+
function m(e) {
|
|
118
|
+
if (x.call(e, "key")) {
|
|
119
119
|
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
120
120
|
if (r && r.isReactWarning) return !1;
|
|
121
121
|
}
|
|
122
122
|
return e.key !== void 0;
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function d(e, r) {
|
|
125
125
|
function t() {
|
|
126
|
-
|
|
126
|
+
h || (h = !0, console.error(
|
|
127
127
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
128
128
|
r
|
|
129
129
|
));
|
|
@@ -133,22 +133,23 @@ function ne() {
|
|
|
133
133
|
configurable: !0
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
var e =
|
|
138
|
-
return
|
|
136
|
+
function D() {
|
|
137
|
+
var e = o(this.type);
|
|
138
|
+
return N[e] || (N[e] = !0, console.error(
|
|
139
139
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
140
140
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
141
141
|
}
|
|
142
|
-
function
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
function L(e, r, t, n, p, A) {
|
|
143
|
+
var a = t.ref;
|
|
144
|
+
return e = {
|
|
145
|
+
$$typeof: j,
|
|
145
146
|
type: e,
|
|
146
147
|
key: r,
|
|
147
|
-
props:
|
|
148
|
-
_owner:
|
|
149
|
-
}, (
|
|
148
|
+
props: t,
|
|
149
|
+
_owner: n
|
|
150
|
+
}, (a !== void 0 ? a : null) !== null ? Object.defineProperty(e, "ref", {
|
|
150
151
|
enumerable: !1,
|
|
151
|
-
get:
|
|
152
|
+
get: D
|
|
152
153
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
153
154
|
configurable: !1,
|
|
154
155
|
enumerable: !1,
|
|
@@ -163,33 +164,33 @@ function ne() {
|
|
|
163
164
|
configurable: !1,
|
|
164
165
|
enumerable: !1,
|
|
165
166
|
writable: !0,
|
|
166
|
-
value:
|
|
167
|
+
value: p
|
|
167
168
|
}), Object.defineProperty(e, "_debugTask", {
|
|
168
169
|
configurable: !1,
|
|
169
170
|
enumerable: !1,
|
|
170
171
|
writable: !0,
|
|
171
|
-
value:
|
|
172
|
+
value: A
|
|
172
173
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
173
174
|
}
|
|
174
|
-
function
|
|
175
|
-
var
|
|
176
|
-
if (
|
|
175
|
+
function w(e, r, t, n, p, A) {
|
|
176
|
+
var a = r.children;
|
|
177
|
+
if (a !== void 0)
|
|
177
178
|
if (n)
|
|
178
|
-
if (
|
|
179
|
-
for (n = 0; n <
|
|
180
|
-
|
|
181
|
-
Object.freeze && Object.freeze(
|
|
179
|
+
if (Q(a)) {
|
|
180
|
+
for (n = 0; n < a.length; n++)
|
|
181
|
+
g(a[n]);
|
|
182
|
+
Object.freeze && Object.freeze(a);
|
|
182
183
|
} else
|
|
183
184
|
console.error(
|
|
184
185
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
185
186
|
);
|
|
186
|
-
else
|
|
187
|
-
if (
|
|
188
|
-
|
|
189
|
-
var
|
|
190
|
-
return
|
|
187
|
+
else g(a);
|
|
188
|
+
if (x.call(r, "key")) {
|
|
189
|
+
a = o(e);
|
|
190
|
+
var c = Object.keys(r).filter(function(K) {
|
|
191
|
+
return K !== "key";
|
|
191
192
|
});
|
|
192
|
-
n = 0 <
|
|
193
|
+
n = 0 < c.length ? "{key: someKey, " + c.join(": ..., ") + ": ...}" : "{key: someKey}", $[a + n] || (c = 0 < c.length ? "{" + c.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
193
194
|
`A props object containing a "key" prop is being spread into JSX:
|
|
194
195
|
let props = %s;
|
|
195
196
|
<%s {...props} />
|
|
@@ -197,80 +198,77 @@ React keys must be passed directly to JSX without using spread:
|
|
|
197
198
|
let props = %s;
|
|
198
199
|
<%s key={someKey} {...props} />`,
|
|
199
200
|
n,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
),
|
|
201
|
+
a,
|
|
202
|
+
c,
|
|
203
|
+
a
|
|
204
|
+
), $[a + n] = !0);
|
|
204
205
|
}
|
|
205
|
-
if (
|
|
206
|
+
if (a = null, t !== void 0 && (i(t), a = "" + t), m(r) && (i(r.key), a = "" + r.key), "key" in r) {
|
|
206
207
|
t = {};
|
|
207
|
-
for (var
|
|
208
|
-
|
|
208
|
+
for (var S in r)
|
|
209
|
+
S !== "key" && (t[S] = r[S]);
|
|
209
210
|
} else t = r;
|
|
210
|
-
return
|
|
211
|
+
return a && d(
|
|
211
212
|
t,
|
|
212
213
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
213
|
-
),
|
|
214
|
+
), L(
|
|
214
215
|
e,
|
|
215
|
-
|
|
216
|
-
u,
|
|
217
|
-
l,
|
|
218
|
-
s(),
|
|
216
|
+
a,
|
|
219
217
|
t,
|
|
220
|
-
|
|
221
|
-
|
|
218
|
+
s(),
|
|
219
|
+
p,
|
|
220
|
+
A
|
|
222
221
|
);
|
|
223
222
|
}
|
|
224
|
-
function
|
|
225
|
-
typeof e == "object" && e !== null && e.$$typeof ===
|
|
223
|
+
function g(e) {
|
|
224
|
+
y(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === T && (e._payload.status === "fulfilled" ? y(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
225
|
+
}
|
|
226
|
+
function y(e) {
|
|
227
|
+
return typeof e == "object" && e !== null && e.$$typeof === j;
|
|
226
228
|
}
|
|
227
|
-
var
|
|
229
|
+
var R = ee, j = Symbol.for("react.transitional.element"), W = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), U = Symbol.for("react.strict_mode"), q = Symbol.for("react.profiler"), J = Symbol.for("react.consumer"), V = Symbol.for("react.context"), z = Symbol.for("react.forward_ref"), G = Symbol.for("react.suspense"), X = Symbol.for("react.suspense_list"), B = Symbol.for("react.memo"), T = Symbol.for("react.lazy"), H = Symbol.for("react.activity"), Z = Symbol.for("react.client.reference"), k = R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, x = Object.prototype.hasOwnProperty, Q = Array.isArray, O = console.createTask ? console.createTask : function() {
|
|
228
230
|
return null;
|
|
229
231
|
};
|
|
230
|
-
|
|
232
|
+
R = {
|
|
231
233
|
react_stack_bottom_frame: function(e) {
|
|
232
234
|
return e();
|
|
233
235
|
}
|
|
234
236
|
};
|
|
235
|
-
var
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
)(),
|
|
239
|
-
|
|
240
|
-
var
|
|
241
|
-
return
|
|
237
|
+
var h, N = {}, C = R.react_stack_bottom_frame.bind(
|
|
238
|
+
R,
|
|
239
|
+
u
|
|
240
|
+
)(), Y = O(f(u)), $ = {};
|
|
241
|
+
E.Fragment = v, E.jsx = function(e, r, t) {
|
|
242
|
+
var n = 1e4 > k.recentlyCreatedOwnerStacks++;
|
|
243
|
+
return w(
|
|
242
244
|
e,
|
|
243
245
|
r,
|
|
244
246
|
t,
|
|
245
247
|
!1,
|
|
246
|
-
n,
|
|
247
|
-
|
|
248
|
-
u ? Error("react-stack-top-frame") : Y,
|
|
249
|
-
u ? O(d(e)) : F
|
|
248
|
+
n ? Error("react-stack-top-frame") : C,
|
|
249
|
+
n ? O(f(e)) : Y
|
|
250
250
|
);
|
|
251
|
-
},
|
|
252
|
-
var
|
|
253
|
-
return
|
|
251
|
+
}, E.jsxs = function(e, r, t) {
|
|
252
|
+
var n = 1e4 > k.recentlyCreatedOwnerStacks++;
|
|
253
|
+
return w(
|
|
254
254
|
e,
|
|
255
255
|
r,
|
|
256
256
|
t,
|
|
257
257
|
!0,
|
|
258
|
-
n,
|
|
259
|
-
|
|
260
|
-
u ? Error("react-stack-top-frame") : Y,
|
|
261
|
-
u ? O(d(e)) : F
|
|
258
|
+
n ? Error("react-stack-top-frame") : C,
|
|
259
|
+
n ? O(f(e)) : Y
|
|
262
260
|
);
|
|
263
261
|
};
|
|
264
|
-
})()),
|
|
262
|
+
})()), E;
|
|
265
263
|
}
|
|
266
|
-
var
|
|
267
|
-
function
|
|
268
|
-
return
|
|
264
|
+
var M;
|
|
265
|
+
function ne() {
|
|
266
|
+
return M || (M = 1, process.env.NODE_ENV === "production" ? b.exports = re() : b.exports = te()), b.exports;
|
|
269
267
|
}
|
|
270
|
-
var le =
|
|
268
|
+
var le = ne();
|
|
271
269
|
export {
|
|
272
|
-
|
|
270
|
+
se as c,
|
|
273
271
|
ue as g,
|
|
274
272
|
le as j,
|
|
275
|
-
|
|
273
|
+
oe as m
|
|
276
274
|
};
|
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
|
|
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 r=new RegExp(t.url);return o&&r.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.3.0-beta.0";let a=[];const g=async e=>{const{method:s}=e.request,n=e.request.url,t=f(s,n,a);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((r,d)=>{o[d]=r})}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
|
|
|
@@ -8,4 +8,4 @@ Please unregister the Service Worker and reload the page to ensure compatibility
|
|
|
8
8
|
To reinstall:
|
|
9
9
|
npx twd-js init public --save
|
|
10
10
|
|
|
11
|
-
Docs: https://brikev.github.io/twd/api-mocking.html#_1-install-mock-service-worker`)},w=e=>{const{type:s,rule:n,version:t}=e.data||{};m(t),s==="ADD_RULE"&&(
|
|
11
|
+
Docs: https://brikev.github.io/twd/api-mocking.html#_1-install-mock-service-worker`)},w=e=>{const{type:s,rule:n,version:t}=e.data||{};m(t),s==="ADD_RULE"&&(a=a.filter(o=>o.alias!==n.alias),a.push(n),console.log("[TWD] Rule added:",n)),s==="CLEAR_RULES"&&(a=[],console.log("[TWD] All rules cleared"))};self.addEventListener("install",()=>{self.skipWaiting()});self.addEventListener("activate",e=>{e.waitUntil(self.clients.claim())});console.log(`[TWD] Mock Service Worker loaded - version ${c}`);self.addEventListener("fetch",g);self.addEventListener("message",w);
|
package/dist/runner.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 w=()=>typeof window<"u"?(window.__TWD_STATE__||(window.__TWD_STATE__={handlers:new Map,beforeEachHooks:new Map,afterEachHooks:new Map,stack:[]}),window.__TWD_STATE__):{handlers:new Map,beforeEachHooks:new Map,afterEachHooks:new Map,stack:[]},u=w(),s=u.handlers,c=u.beforeEachHooks,h=u.afterEachHooks,o=u.stack,l=()=>Math.random().toString(36).substr(2,9),d=(r,e)=>{const t=l(),n=o.at(-1);s.set(t,{id:t,name:r,type:"suite",children:[],logs:[],depth:o.length,parent:n,handler:e}),n&&s.get(n).children.push(t),o.push(t),e(),o.pop()};d.only=(r,e)=>{const t=l(),n=o.at(-1);s.set(t,{id:t,name:r,type:"suite",children:[],logs:[],depth:o.length,parent:n,handler:e,only:!0}),n&&s.get(n).children.push(t),o.push(t),e(),o.pop()};d.skip=(r,e)=>{const t=l(),n=o.at(-1);s.set(t,{id:t,name:r,type:"suite",children:[],logs:[],depth:o.length,parent:n,handler:e,skip:!0}),n&&s.get(n).children.push(t),o.push(t),e(),o.pop()};const g=(r,e)=>{const t=l(),n=o.at(-1),i={id:t,name:r,type:"test",depth:o.length,handler:e,logs:[],parent:n};n&&s.get(n).children.push(t),s.set(t,i)};g.only=(r,e)=>{const t=l(),n=o.at(-1),i={id:t,name:r,type:"test",depth:o.length,handler:e,logs:[],parent:n,only:!0};n&&s.get(n).children.push(t),s.set(t,i)};g.skip=(r,e)=>{const t=l(),n=o.at(-1),i={id:t,name:r,type:"test",depth:o.length,handler:e||(()=>{}),logs:[],parent:n,skip:!0};n&&s.get(n).children.push(t),s.set(t,i)};const S=r=>{const e=o.at(-1);if(!e)throw new Error("beforeEach() must be inside a describe()");c.has(e)||c.set(e,[]),c.get(e).push(r)},b=r=>{const e=o.at(-1);if(!e)throw new Error("afterEach() must be inside a describe()");h.has(e)||h.set(e,[]),h.get(e).push(r)},E=r=>{const e=[],t=[];let n=r;for(;n;)c.has(n)&&e.unshift(...c.get(n)),h.has(n)&&t.push(...h.get(n)),n=s.get(n)?.parent;return{before:e,after:t}},f=r=>{const e=s.get(r);return e?e.only?!0:e.children?e.children.some(t=>f(t)):!1:!1},T=r=>{let e=s.get(r);for(;e?.parent;){const t=s.get(e.parent);if(t?.only)return!0;e=t}return!1},y=r=>{let e=s.get(r);for(;e;){if(e.skip)return!0;if(!e.parent)break;e=s.get(e.parent)}return!1},_=()=>{s.clear(),c.clear(),h.clear()};class k{events;constructor(e){this.events=e}async runAll(){const e=Array.from(s.values()).filter(n=>!n.parent&&n.type==="suite"),t=Array.from(s.values()).some(n=>n.only);for(const n of e)await this.runSuite(n,t);return s}async runSingle(e){const t=s.get(e);if(!t||t.type!=="test")return;await this.runTest(t,!1)}async runSuite(e,t){if(y(e.id)&&!f(e.id)){this.events.onSkip?.(e);return}if(t&&!f(e.id))return;this.events.onSuiteStart?.(e);const i=(e.children||[]).map(a=>s.get(a));for(const a of i)a.type==="suite"?await this.runSuite(a,t):a.type==="test"&&await this.runTest(a,t);this.events.onSuiteEnd?.(e)}async runTest(e,t){if((y(e.id)||e.skip)&&!e.only){this.events.onSkip(e);return}const i=T(e.id);if(t&&!e.only&&!i){this.events.onSkip(e);return}this.events.onStart?.(e);const a=E(e.parent);try{for(const p of a.before)await p();e.logs=[],await e.handler(),this.events.onPass(e)}catch(p){this.events.onFail(e,p)}finally{for(const p of a.after)await p()}}}window.__testRunner=k;exports.TestRunner=k;exports.afterEach=b;exports.beforeEach=S;exports.clearTests=_;exports.describe=d;exports.handlers=s;exports.it=g;
|
package/dist/runner.es.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
const
|
|
1
|
+
const k = () => typeof window < "u" ? (window.__TWD_STATE__ || (window.__TWD_STATE__ = {
|
|
2
|
+
handlers: /* @__PURE__ */ new Map(),
|
|
3
|
+
beforeEachHooks: /* @__PURE__ */ new Map(),
|
|
4
|
+
afterEachHooks: /* @__PURE__ */ new Map(),
|
|
5
|
+
stack: []
|
|
6
|
+
}), window.__TWD_STATE__) : {
|
|
7
|
+
handlers: /* @__PURE__ */ new Map(),
|
|
8
|
+
beforeEachHooks: /* @__PURE__ */ new Map(),
|
|
9
|
+
afterEachHooks: /* @__PURE__ */ new Map(),
|
|
10
|
+
stack: []
|
|
11
|
+
}, u = k(), r = u.handlers, c = u.beforeEachHooks, h = u.afterEachHooks, o = u.stack, p = () => Math.random().toString(36).substr(2, 9), g = (s, t) => {
|
|
2
12
|
const e = p(), n = o.at(-1);
|
|
3
13
|
r.set(e, {
|
|
4
14
|
id: e,
|
|
@@ -11,7 +21,7 @@ const r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), h = /* @__PU
|
|
|
11
21
|
handler: t
|
|
12
22
|
}), n && r.get(n).children.push(e), o.push(e), t(), o.pop();
|
|
13
23
|
};
|
|
14
|
-
|
|
24
|
+
g.only = (s, t) => {
|
|
15
25
|
const e = p(), n = o.at(-1);
|
|
16
26
|
r.set(e, {
|
|
17
27
|
id: e,
|
|
@@ -25,7 +35,7 @@ d.only = (s, t) => {
|
|
|
25
35
|
only: !0
|
|
26
36
|
}), n && r.get(n).children.push(e), o.push(e), t(), o.pop();
|
|
27
37
|
};
|
|
28
|
-
|
|
38
|
+
g.skip = (s, t) => {
|
|
29
39
|
const e = p(), n = o.at(-1);
|
|
30
40
|
r.set(e, {
|
|
31
41
|
id: e,
|
|
@@ -39,7 +49,7 @@ d.skip = (s, t) => {
|
|
|
39
49
|
skip: !0
|
|
40
50
|
}), n && r.get(n).children.push(e), o.push(e), t(), o.pop();
|
|
41
51
|
};
|
|
42
|
-
const
|
|
52
|
+
const y = (s, t) => {
|
|
43
53
|
const e = p(), n = o.at(-1), i = {
|
|
44
54
|
id: e,
|
|
45
55
|
name: s,
|
|
@@ -51,7 +61,7 @@ const g = (s, t) => {
|
|
|
51
61
|
};
|
|
52
62
|
n && r.get(n).children.push(e), r.set(e, i);
|
|
53
63
|
};
|
|
54
|
-
|
|
64
|
+
y.only = (s, t) => {
|
|
55
65
|
const e = p(), n = o.at(-1), i = {
|
|
56
66
|
id: e,
|
|
57
67
|
name: s,
|
|
@@ -64,7 +74,7 @@ g.only = (s, t) => {
|
|
|
64
74
|
};
|
|
65
75
|
n && r.get(n).children.push(e), r.set(e, i);
|
|
66
76
|
};
|
|
67
|
-
|
|
77
|
+
y.skip = (s, t) => {
|
|
68
78
|
const e = p(), n = o.at(-1), i = {
|
|
69
79
|
id: e,
|
|
70
80
|
name: s,
|
|
@@ -78,24 +88,24 @@ g.skip = (s, t) => {
|
|
|
78
88
|
};
|
|
79
89
|
n && r.get(n).children.push(e), r.set(e, i);
|
|
80
90
|
};
|
|
81
|
-
const
|
|
91
|
+
const _ = (s) => {
|
|
82
92
|
const t = o.at(-1);
|
|
83
93
|
if (!t) throw new Error("beforeEach() must be inside a describe()");
|
|
84
|
-
|
|
94
|
+
c.has(t) || c.set(t, []), c.get(t).push(s);
|
|
85
95
|
}, b = (s) => {
|
|
86
96
|
const t = o.at(-1);
|
|
87
97
|
if (!t) throw new Error("afterEach() must be inside a describe()");
|
|
88
98
|
h.has(t) || h.set(t, []), h.get(t).push(s);
|
|
89
|
-
},
|
|
99
|
+
}, w = (s) => {
|
|
90
100
|
const t = [], e = [];
|
|
91
101
|
let n = s;
|
|
92
102
|
for (; n; )
|
|
93
|
-
|
|
103
|
+
c.has(n) && t.unshift(...c.get(n)), h.has(n) && e.push(...h.get(n)), n = r.get(n)?.parent;
|
|
94
104
|
return { before: t, after: e };
|
|
95
|
-
},
|
|
105
|
+
}, f = (s) => {
|
|
96
106
|
const t = r.get(s);
|
|
97
|
-
return t ? t.only ? !0 : t.children ? t.children.some((e) =>
|
|
98
|
-
},
|
|
107
|
+
return t ? t.only ? !0 : t.children ? t.children.some((e) => f(e)) : !1 : !1;
|
|
108
|
+
}, S = (s) => {
|
|
99
109
|
let t = r.get(s);
|
|
100
110
|
for (; t?.parent; ) {
|
|
101
111
|
const e = r.get(t.parent);
|
|
@@ -103,7 +113,7 @@ const w = (s) => {
|
|
|
103
113
|
t = e;
|
|
104
114
|
}
|
|
105
115
|
return !1;
|
|
106
|
-
},
|
|
116
|
+
}, d = (s) => {
|
|
107
117
|
let t = r.get(s);
|
|
108
118
|
for (; t; ) {
|
|
109
119
|
if (t.skip) return !0;
|
|
@@ -111,10 +121,10 @@ const w = (s) => {
|
|
|
111
121
|
t = r.get(t.parent);
|
|
112
122
|
}
|
|
113
123
|
return !1;
|
|
114
|
-
},
|
|
115
|
-
r.clear(),
|
|
124
|
+
}, T = () => {
|
|
125
|
+
r.clear(), c.clear(), h.clear();
|
|
116
126
|
};
|
|
117
|
-
class
|
|
127
|
+
class E {
|
|
118
128
|
events;
|
|
119
129
|
constructor(t) {
|
|
120
130
|
this.events = t;
|
|
@@ -133,46 +143,46 @@ class S {
|
|
|
133
143
|
await this.runTest(e, !1);
|
|
134
144
|
}
|
|
135
145
|
async runSuite(t, e) {
|
|
136
|
-
if (
|
|
146
|
+
if (d(t.id) && !f(t.id)) {
|
|
137
147
|
this.events.onSkip?.(t);
|
|
138
148
|
return;
|
|
139
149
|
}
|
|
140
|
-
if (e && !
|
|
150
|
+
if (e && !f(t.id)) return;
|
|
141
151
|
this.events.onSuiteStart?.(t);
|
|
142
|
-
const i = (t.children || []).map((
|
|
143
|
-
for (const
|
|
144
|
-
|
|
152
|
+
const i = (t.children || []).map((a) => r.get(a));
|
|
153
|
+
for (const a of i)
|
|
154
|
+
a.type === "suite" ? await this.runSuite(a, e) : a.type === "test" && await this.runTest(a, e);
|
|
145
155
|
this.events.onSuiteEnd?.(t);
|
|
146
156
|
}
|
|
147
157
|
async runTest(t, e) {
|
|
148
|
-
if ((
|
|
158
|
+
if ((d(t.id) || t.skip) && !t.only) {
|
|
149
159
|
this.events.onSkip(t);
|
|
150
160
|
return;
|
|
151
161
|
}
|
|
152
|
-
const i =
|
|
162
|
+
const i = S(t.id);
|
|
153
163
|
if (e && !t.only && !i) {
|
|
154
164
|
this.events.onSkip(t);
|
|
155
165
|
return;
|
|
156
166
|
}
|
|
157
167
|
this.events.onStart?.(t);
|
|
158
|
-
const
|
|
168
|
+
const a = w(t.parent);
|
|
159
169
|
try {
|
|
160
|
-
for (const l of
|
|
170
|
+
for (const l of a.before) await l();
|
|
161
171
|
t.logs = [], await t.handler(), this.events.onPass(t);
|
|
162
172
|
} catch (l) {
|
|
163
173
|
this.events.onFail(t, l);
|
|
164
174
|
} finally {
|
|
165
|
-
for (const l of
|
|
175
|
+
for (const l of a.after) await l();
|
|
166
176
|
}
|
|
167
177
|
}
|
|
168
178
|
}
|
|
169
|
-
window.__testRunner =
|
|
179
|
+
window.__testRunner = E;
|
|
170
180
|
export {
|
|
171
|
-
|
|
181
|
+
E as TestRunner,
|
|
172
182
|
b as afterEach,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
183
|
+
_ as beforeEach,
|
|
184
|
+
T as clearTests,
|
|
185
|
+
g as describe,
|
|
176
186
|
r as handlers,
|
|
177
|
-
|
|
187
|
+
y as it
|
|
178
188
|
};
|
package/dist/ui.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./jsx-runtime-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./jsx-runtime-CjngqUuo.js");function r({name:n,children:o}){const e=t.getMockForComponent(n);return e?t.jsxRuntimeExports.jsx(e,{...o.props}):o}exports.MockedComponent=r;
|
package/dist/ui.es.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twd-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-beta.0",
|
|
4
4
|
"description": "Test While Developing (TWD) - in-browser testing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "BRIKEV",
|
|
@@ -22,7 +22,13 @@
|
|
|
22
22
|
".": {
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
24
|
"import": "./dist/index.es.js",
|
|
25
|
-
"require": "./dist/index.cjs.js"
|
|
25
|
+
"require": "./dist/index.cjs.js",
|
|
26
|
+
"default": "./dist/index.es.js"
|
|
27
|
+
},
|
|
28
|
+
"./bundled": {
|
|
29
|
+
"types": "./dist/bundled.d.ts",
|
|
30
|
+
"import": "./dist/bundled.es.js",
|
|
31
|
+
"require": "./dist/bundled.umd.js"
|
|
26
32
|
},
|
|
27
33
|
"./runner": {
|
|
28
34
|
"types": "./dist/runner.d.ts",
|
|
@@ -54,7 +60,7 @@
|
|
|
54
60
|
"node": ">=16"
|
|
55
61
|
},
|
|
56
62
|
"scripts": {
|
|
57
|
-
"build": "vite build && vite build -c vite.sw.config.js && cp src/cli/installsw.js dist/cli.js",
|
|
63
|
+
"build": "vite build && vite build -c vite.sw.config.js && vite build -c vite.bundle.config.ts && cp src/cli/installsw.js dist/cli.js",
|
|
58
64
|
"test": "vitest",
|
|
59
65
|
"test:ci": "vitest --run --coverage",
|
|
60
66
|
"conventional-changelog": "conventional-changelog -i CHANGELOG.md",
|