twd-js 1.2.2 → 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 +25 -25
- package/dist/index.d.ts +6 -2
- package/dist/index.es.js +638 -623
- 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-ci.cjs.js +1 -1
- package/dist/runner-ci.es.js +22 -33
- 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 +14 -9
- package/dist/_commonjsHelpers-C6fGbg64.mjs +0 -6
- package/dist/_commonjsHelpers-DwGv2jUC.js +0 -1
- package/dist/jsx-runtime-DN5DOl8k.js +0 -6
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",
|
|
@@ -70,17 +76,17 @@
|
|
|
70
76
|
"devDependencies": {
|
|
71
77
|
"@testing-library/jest-dom": "^6.9.1",
|
|
72
78
|
"@testing-library/react": "^16.3.0",
|
|
73
|
-
"@types/react": "^19.2.
|
|
79
|
+
"@types/react": "^19.2.7",
|
|
74
80
|
"@types/react-dom": "^19.2.3",
|
|
75
81
|
"@vitejs/plugin-react": "^5.1.1",
|
|
76
|
-
"@vitest/coverage-v8": "^4.0.
|
|
82
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
77
83
|
"conventional-changelog": "^7.1.1",
|
|
78
84
|
"jsdom": "^27.2.0",
|
|
79
85
|
"typescript": "^5.9.3",
|
|
80
|
-
"vite": "^7.2.
|
|
86
|
+
"vite": "^7.2.6",
|
|
81
87
|
"vite-plugin-dts": "^4.5.4",
|
|
82
88
|
"vitepress": "^2.0.0-alpha.12",
|
|
83
|
-
"vitest": "^4.0.
|
|
89
|
+
"vitest": "^4.0.15"
|
|
84
90
|
},
|
|
85
91
|
"keywords": [
|
|
86
92
|
"testing",
|
|
@@ -96,7 +102,6 @@
|
|
|
96
102
|
"@testing-library/dom": "^10.4.1",
|
|
97
103
|
"@testing-library/user-event": "^14.6.1",
|
|
98
104
|
"@types/chai": "^5.2.3",
|
|
99
|
-
"chai": "^6.2.1"
|
|
100
|
-
"picocolors": "^1.1.1"
|
|
105
|
+
"chai": "^6.2.1"
|
|
101
106
|
}
|
|
102
107
|
}
|
|
@@ -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;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";const re=require("react"),w=new Map,te=(a,i)=>{w.set(a,i)};function ne(){w.clear()}const oe=a=>w.get(a);var v={exports:{}},_={};var I;function ae(){if(I)return _;I=1;var a=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function m(d,s,c){var E=null;if(c!==void 0&&(E=""+c),s.key!==void 0&&(E=""+s.key),"key"in s){c={};for(var R in s)R!=="key"&&(c[R]=s[R])}else c=s;return s=c.ref,{$$typeof:a,type:d,key:E,ref:s!==void 0?s:null,props:c}}return _.Fragment=i,_.jsx=m,_.jsxs=m,_}var b={};var $;function se(){return $||($=1,process.env.NODE_ENV!=="production"&&(function(){function a(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Q?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case T:return"Fragment";case J:return"Profiler";case q:return"StrictMode";case X:return"Suspense";case B:return"SuspenseList";case Z:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case U:return"Portal";case V:return(e.displayName||"Context")+".Provider";case z:return(e._context.displayName||"Context")+".Consumer";case G:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case H:return r=e.displayName||null,r!==null?r:a(e.type)||"Memo";case h:r=e._payload,e=e._init;try{return a(e(r))}catch{}}return null}function i(e){return""+e}function m(e){try{i(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),i(e)}}function d(e){if(e===T)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===h)return"<...>";try{var r=a(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function s(){var e=k.A;return e===null?null:e.getOwner()}function c(){return Error("react-stack-top-frame")}function E(e){if(y.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function R(e,r){function t(){C||(C=!0,console.error("%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)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function L(){var e=a(this.type);return N[e]||(N[e]=!0,console.error("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.")),e=this.props.ref,e!==void 0?e:null}function W(e,r,t,n,l,u,A,S){return t=u.ref,e={$$typeof:x,type:e,key:r,props:u,_owner:l},(t!==void 0?t:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:L}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:A}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:S}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function g(e,r,t,n,l,u,A,S){var o=r.children;if(o!==void 0)if(n)if(K(o)){for(n=0;n<o.length;n++)j(o[n]);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else j(o);if(y.call(r,"key")){o=a(e);var f=Object.keys(r).filter(function(ee){return ee!=="key"});n=0<f.length?"{key: someKey, "+f.join(": ..., ")+": ...}":"{key: someKey}",F[o+n]||(f=0<f.length?"{"+f.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
|
-
let props = %s;
|
|
3
|
-
<%s {...props} />
|
|
4
|
-
React keys must be passed directly to JSX without using spread:
|
|
5
|
-
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,n,o,f,o),F[o+n]=!0)}if(o=null,t!==void 0&&(m(t),o=""+t),E(r)&&(m(r.key),o=""+r.key),"key"in r){t={};for(var P in r)P!=="key"&&(t[P]=r[P])}else t=r;return o&&R(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),W(e,o,u,l,s(),t,A,S)}function j(e){typeof e=="object"&&e!==null&&e.$$typeof===x&&e._store&&(e._store.validated=1)}var p=re,x=Symbol.for("react.transitional.element"),U=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),J=Symbol.for("react.profiler"),z=Symbol.for("react.consumer"),V=Symbol.for("react.context"),G=Symbol.for("react.forward_ref"),X=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),Z=Symbol.for("react.activity"),Q=Symbol.for("react.client.reference"),k=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,y=Object.prototype.hasOwnProperty,K=Array.isArray,O=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(e){return e()}};var C,N={},Y=p.react_stack_bottom_frame.bind(p,c)(),M=O(d(c)),F={};b.Fragment=T,b.jsx=function(e,r,t,n,l){var u=1e4>k.recentlyCreatedOwnerStacks++;return g(e,r,t,!1,n,l,u?Error("react-stack-top-frame"):Y,u?O(d(e)):M)},b.jsxs=function(e,r,t,n,l){var u=1e4>k.recentlyCreatedOwnerStacks++;return g(e,r,t,!0,n,l,u?Error("react-stack-top-frame"):Y,u?O(d(e)):M)}})()),b}var D;function ce(){return D||(D=1,process.env.NODE_ENV==="production"?v.exports=ae():v.exports=se()),v.exports}var ue=ce();exports.clearComponentMocks=ne;exports.getMockForComponent=oe;exports.jsxRuntimeExports=ue;exports.mockComponent=te;
|