twd-js 0.6.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/global.d.ts +8 -0
- package/dist/index.cjs.js +320 -0
- package/dist/index.d.ts +1 -2
- package/dist/{twd.es.js → index.es.js} +3882 -3881
- package/dist/mock-sw.js +1 -1
- package/dist/runner-ci.cjs.js +1 -0
- package/dist/runner-ci.d.ts +12 -0
- package/dist/runner-ci.es.js +34 -0
- package/dist/runner.cjs.js +1 -0
- package/dist/runner.d.ts +41 -0
- package/dist/runner.es.js +121 -0
- package/dist/twd.d.ts +13 -34
- package/dist/ui/TestList.d.ts +14 -4
- package/dist/ui/TestListItem.d.ts +16 -6
- package/dist/ui/buildTreeFromHandlers.d.ts +14 -0
- package/dist/vite-plugin.cjs.js +1 -0
- package/dist/vite-plugin.d.ts +1 -0
- package/dist/vite-plugin.es.js +18 -0
- package/package.json +25 -7
- package/dist/twd.umd.js +0 -320
- package/dist/twdRegistry.d.ts +0 -18
- package/dist/ui/groupTests.d.ts +0 -7
package/dist/mock-sw.js
CHANGED
|
@@ -1 +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");self.addEventListener("fetch",y);self.addEventListener("message",p);
|
|
@@ -0,0 +1 @@
|
|
|
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=$;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Handler } from './runner';
|
|
2
|
+
interface TestResult {
|
|
3
|
+
id: string;
|
|
4
|
+
status: 'pass' | 'fail' | 'skip';
|
|
5
|
+
error?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const reportResults: (handlers: Handler[], testResults: TestResult[]) => void;
|
|
8
|
+
export declare const executeTests: () => Promise<{
|
|
9
|
+
handlers: Handler[];
|
|
10
|
+
testStatus: TestResult[];
|
|
11
|
+
}>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
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);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
for (const s of f) o(s);
|
|
15
|
+
}, g = async () => {
|
|
16
|
+
const e = window.__testRunner, t = [], o = await new e({
|
|
17
|
+
onStart: () => {
|
|
18
|
+
},
|
|
19
|
+
onPass: (s) => {
|
|
20
|
+
t.push({ id: s.id, status: "pass" });
|
|
21
|
+
},
|
|
22
|
+
onFail: (s, r) => {
|
|
23
|
+
t.push({ id: s.id, status: "fail", error: r.message });
|
|
24
|
+
},
|
|
25
|
+
onSkip: (s) => {
|
|
26
|
+
t.push({ id: s.id, status: "skip" });
|
|
27
|
+
}
|
|
28
|
+
}).runAll();
|
|
29
|
+
return { handlers: Array.from(o.values()), testStatus: t };
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
g as executeTests,
|
|
33
|
+
y as reportResults
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=new Map,i=new Map,c=new Map,a=[],h=()=>Math.random().toString(36).substr(2,9),f=(o,t)=>{const s=h(),e=a.at(-1);r.set(s,{id:s,name:o,type:"suite",children:[],logs:[],depth:a.length,parent:e,handler:t}),e&&r.get(e).children.push(s),a.push(s),t(),a.pop()},l=(o,t)=>{const s=h(),e=a.at(-1),n={id:s,name:o,type:"test",depth:a.length,handler:t,logs:[],parent:e};e&&r.get(e).children.push(s),r.set(s,n)};l.only=(o,t)=>{const s=h(),e=a.at(-1),n={id:s,name:o,type:"test",depth:a.length,handler:t,logs:[],parent:e,only:!0};e&&r.get(e).children.push(s),r.set(s,n)};l.skip=(o,t)=>{const s=h(),e=a.at(-1),n={id:s,name:o,type:"test",depth:a.length,handler:t||(()=>{}),logs:[],parent:e,skip:!0};e&&r.get(e).children.push(s),r.set(s,n)};const p=o=>{const t=a.at(-1);if(!t)throw new Error("beforeEach() must be inside a describe()");i.has(t)||i.set(t,[]),i.get(t).push(o)},d=o=>{const t=a.at(-1);if(!t)throw new Error("afterEach() must be inside a describe()");c.has(t)||c.set(t,[]),c.get(t).push(o)},g=o=>{const t=[],s=[];let e=o;for(;e;)i.has(e)&&t.unshift(...i.get(e)),c.has(e)&&s.push(...c.get(e)),e=r.get(e)?.parent;return{before:t,after:s}},y=()=>{r.clear(),i.clear(),c.clear()};class u{events;constructor(t){this.events=t}async runAll(){const t=Array.from(r.values()).filter(e=>!e.parent&&e.type==="suite"),s=Array.from(r.values()).some(e=>e.only);for(const e of t)await this.runSuite(e,s);return r}async runSingle(t){const s=r.get(t);if(!s||s.type!=="test")return;await this.runTest(s,!1)}async runSuite(t,s){this.events.onSuiteStart?.(t);const e=(t.children||[]).map(n=>r.get(n));for(const n of e)n.type==="suite"?await this.runSuite(n,s):n.type==="test"&&await this.runTest(n,s);this.events.onSuiteEnd?.(t)}async runTest(t,s){if(t.skip){this.events.onSkip(t);return}if(s&&!t.only)return;this.events.onStart?.(t);const e=g(t.parent);try{for(const n of e.before)await n();t.logs=[],await t.handler(),this.events.onPass(t)}catch(n){this.events.onFail(t,n)}finally{for(const n of e.after)await n()}}}window.__testRunner=u;exports.TestRunner=u;exports.afterEach=d;exports.beforeEach=p;exports.clearTests=y;exports.describe=f;exports.handlers=r;exports.it=l;
|
package/dist/runner.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface Handler {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
parent?: string;
|
|
5
|
+
handler: () => void | Promise<void>;
|
|
6
|
+
children?: string[];
|
|
7
|
+
type: 'suite' | 'test';
|
|
8
|
+
status?: 'idle' | 'pass' | 'fail' | 'skip' | 'running';
|
|
9
|
+
logs: string[];
|
|
10
|
+
depth: number;
|
|
11
|
+
only?: boolean;
|
|
12
|
+
skip?: boolean;
|
|
13
|
+
}
|
|
14
|
+
type HookFn = () => void | Promise<void>;
|
|
15
|
+
export declare const handlers: Map<string, Handler>;
|
|
16
|
+
export declare const describe: (name: string, handler: () => void) => void;
|
|
17
|
+
export declare const it: {
|
|
18
|
+
(name: string, handler: () => void | Promise<void>): void;
|
|
19
|
+
only(name: string, handler: () => void | Promise<void>): void;
|
|
20
|
+
skip(name: string, handler?: () => void | Promise<void>): void;
|
|
21
|
+
};
|
|
22
|
+
export declare const beforeEach: (fn: HookFn) => void;
|
|
23
|
+
export declare const afterEach: (fn: HookFn) => void;
|
|
24
|
+
export declare const clearTests: () => void;
|
|
25
|
+
export interface RunnerEvents {
|
|
26
|
+
onStart: (test: Handler) => void;
|
|
27
|
+
onPass: (test: Handler) => void;
|
|
28
|
+
onFail: (test: Handler, error: Error) => void;
|
|
29
|
+
onSkip: (test: Handler) => void;
|
|
30
|
+
onSuiteStart?: (suite: Handler) => void;
|
|
31
|
+
onSuiteEnd?: (suite: Handler) => void;
|
|
32
|
+
}
|
|
33
|
+
export declare class TestRunner {
|
|
34
|
+
private events;
|
|
35
|
+
constructor(events: RunnerEvents);
|
|
36
|
+
runAll(): Promise<Map<string, Handler>>;
|
|
37
|
+
runSingle(id: string): Promise<void>;
|
|
38
|
+
private runSuite;
|
|
39
|
+
private runTest;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), a = [], h = () => Math.random().toString(36).substr(2, 9), p = (o, t) => {
|
|
2
|
+
const s = h(), e = a.at(-1);
|
|
3
|
+
r.set(s, {
|
|
4
|
+
id: s,
|
|
5
|
+
name: o,
|
|
6
|
+
type: "suite",
|
|
7
|
+
children: [],
|
|
8
|
+
logs: [],
|
|
9
|
+
depth: a.length,
|
|
10
|
+
parent: e,
|
|
11
|
+
handler: t
|
|
12
|
+
}), e && r.get(e).children.push(s), a.push(s), t(), a.pop();
|
|
13
|
+
}, l = (o, t) => {
|
|
14
|
+
const s = h(), e = a.at(-1), n = {
|
|
15
|
+
id: s,
|
|
16
|
+
name: o,
|
|
17
|
+
type: "test",
|
|
18
|
+
depth: a.length,
|
|
19
|
+
handler: t,
|
|
20
|
+
logs: [],
|
|
21
|
+
parent: e
|
|
22
|
+
};
|
|
23
|
+
e && r.get(e).children.push(s), r.set(s, n);
|
|
24
|
+
};
|
|
25
|
+
l.only = (o, t) => {
|
|
26
|
+
const s = h(), e = a.at(-1), n = {
|
|
27
|
+
id: s,
|
|
28
|
+
name: o,
|
|
29
|
+
type: "test",
|
|
30
|
+
depth: a.length,
|
|
31
|
+
handler: t,
|
|
32
|
+
logs: [],
|
|
33
|
+
parent: e,
|
|
34
|
+
only: !0
|
|
35
|
+
};
|
|
36
|
+
e && r.get(e).children.push(s), r.set(s, n);
|
|
37
|
+
};
|
|
38
|
+
l.skip = (o, t) => {
|
|
39
|
+
const s = h(), e = a.at(-1), n = {
|
|
40
|
+
id: s,
|
|
41
|
+
name: o,
|
|
42
|
+
type: "test",
|
|
43
|
+
depth: a.length,
|
|
44
|
+
handler: t || (() => {
|
|
45
|
+
}),
|
|
46
|
+
logs: [],
|
|
47
|
+
parent: e,
|
|
48
|
+
skip: !0
|
|
49
|
+
};
|
|
50
|
+
e && r.get(e).children.push(s), r.set(s, n);
|
|
51
|
+
};
|
|
52
|
+
const d = (o) => {
|
|
53
|
+
const t = a.at(-1);
|
|
54
|
+
if (!t) throw new Error("beforeEach() must be inside a describe()");
|
|
55
|
+
i.has(t) || i.set(t, []), i.get(t).push(o);
|
|
56
|
+
}, g = (o) => {
|
|
57
|
+
const t = a.at(-1);
|
|
58
|
+
if (!t) throw new Error("afterEach() must be inside a describe()");
|
|
59
|
+
c.has(t) || c.set(t, []), c.get(t).push(o);
|
|
60
|
+
}, u = (o) => {
|
|
61
|
+
const t = [], s = [];
|
|
62
|
+
let e = o;
|
|
63
|
+
for (; e; )
|
|
64
|
+
i.has(e) && t.unshift(...i.get(e)), c.has(e) && s.push(...c.get(e)), e = r.get(e)?.parent;
|
|
65
|
+
return { before: t, after: s };
|
|
66
|
+
}, y = () => {
|
|
67
|
+
r.clear(), i.clear(), c.clear();
|
|
68
|
+
};
|
|
69
|
+
class f {
|
|
70
|
+
events;
|
|
71
|
+
constructor(t) {
|
|
72
|
+
this.events = t;
|
|
73
|
+
}
|
|
74
|
+
async runAll() {
|
|
75
|
+
const t = Array.from(r.values()).filter(
|
|
76
|
+
(e) => !e.parent && e.type === "suite"
|
|
77
|
+
), s = Array.from(r.values()).some((e) => e.only);
|
|
78
|
+
for (const e of t)
|
|
79
|
+
await this.runSuite(e, s);
|
|
80
|
+
return r;
|
|
81
|
+
}
|
|
82
|
+
async runSingle(t) {
|
|
83
|
+
const s = r.get(t);
|
|
84
|
+
if (!s || s.type !== "test") return;
|
|
85
|
+
await this.runTest(s, !1);
|
|
86
|
+
}
|
|
87
|
+
async runSuite(t, s) {
|
|
88
|
+
this.events.onSuiteStart?.(t);
|
|
89
|
+
const e = (t.children || []).map((n) => r.get(n));
|
|
90
|
+
for (const n of e)
|
|
91
|
+
n.type === "suite" ? await this.runSuite(n, s) : n.type === "test" && await this.runTest(n, s);
|
|
92
|
+
this.events.onSuiteEnd?.(t);
|
|
93
|
+
}
|
|
94
|
+
async runTest(t, s) {
|
|
95
|
+
if (t.skip) {
|
|
96
|
+
this.events.onSkip(t);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (s && !t.only) return;
|
|
100
|
+
this.events.onStart?.(t);
|
|
101
|
+
const e = u(t.parent);
|
|
102
|
+
try {
|
|
103
|
+
for (const n of e.before) await n();
|
|
104
|
+
t.logs = [], await t.handler(), this.events.onPass(t);
|
|
105
|
+
} catch (n) {
|
|
106
|
+
this.events.onFail(t, n);
|
|
107
|
+
} finally {
|
|
108
|
+
for (const n of e.after) await n();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
window.__testRunner = f;
|
|
113
|
+
export {
|
|
114
|
+
f as TestRunner,
|
|
115
|
+
g as afterEach,
|
|
116
|
+
d as beforeEach,
|
|
117
|
+
y as clearTests,
|
|
118
|
+
p as describe,
|
|
119
|
+
r as handlers,
|
|
120
|
+
l as it
|
|
121
|
+
};
|
package/dist/twd.d.ts
CHANGED
|
@@ -1,40 +1,6 @@
|
|
|
1
1
|
import { Options, Rule } from './commands/mockBridge';
|
|
2
2
|
import { TWDElemAPI } from './twd-types';
|
|
3
3
|
import { URLCommandAPI } from './commands/url';
|
|
4
|
-
/**
|
|
5
|
-
* Stores the function to run before each test.
|
|
6
|
-
*/
|
|
7
|
-
declare let beforeEachFn: (() => void | Promise<void>) | null;
|
|
8
|
-
/**
|
|
9
|
-
* Registers a function to run before each test.
|
|
10
|
-
* @example
|
|
11
|
-
* beforeEach(() => { ... });
|
|
12
|
-
*/
|
|
13
|
-
export declare const beforeEach: (fn: typeof beforeEachFn) => void;
|
|
14
|
-
/**
|
|
15
|
-
* Groups related tests together.
|
|
16
|
-
* @example
|
|
17
|
-
* describe("My group", () => { ... });
|
|
18
|
-
*/
|
|
19
|
-
export declare const describe: (name: string, fn: () => void) => void;
|
|
20
|
-
/**
|
|
21
|
-
* Defines a test case.
|
|
22
|
-
* @example
|
|
23
|
-
* it("does something", async () => { ... });
|
|
24
|
-
*/
|
|
25
|
-
export declare const it: (name: string, fn: () => Promise<void> | void) => void;
|
|
26
|
-
/**
|
|
27
|
-
* Defines an exclusive test case (only this runs).
|
|
28
|
-
* @example
|
|
29
|
-
* itOnly("runs only this", async () => { ... });
|
|
30
|
-
*/
|
|
31
|
-
export declare const itOnly: (name: string, fn: () => Promise<void> | void) => void;
|
|
32
|
-
/**
|
|
33
|
-
* Skips a test case.
|
|
34
|
-
* @example
|
|
35
|
-
* itSkip("skipped test", () => { ... });
|
|
36
|
-
*/
|
|
37
|
-
export declare const itSkip: (name: string, _fn: () => Promise<void> | void) => void;
|
|
38
4
|
interface TWDAPI {
|
|
39
5
|
/**
|
|
40
6
|
* Finds an element by selector and returns the TWD API for it.
|
|
@@ -49,6 +15,19 @@ interface TWDAPI {
|
|
|
49
15
|
*
|
|
50
16
|
*/
|
|
51
17
|
get: (selector: string) => Promise<TWDElemAPI>;
|
|
18
|
+
/**
|
|
19
|
+
* Sets the value of an input element and dispatches an input event. We recommend using this only for range, color, time inputs.
|
|
20
|
+
* @param el The input element
|
|
21
|
+
* @param value The value to set
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const input = await twd.get("input[type='time']");
|
|
26
|
+
* twd.setInputValue(input.el, "13:30");
|
|
27
|
+
*
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
setInputValue: (el: Element, value: string) => void;
|
|
52
31
|
/**
|
|
53
32
|
* Finds multiple elements by selector and returns an array of TWD APIs for them.
|
|
54
33
|
* @param selector CSS selector
|
package/dist/ui/TestList.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
interface Test {
|
|
2
|
+
name: string;
|
|
3
|
+
depth: number;
|
|
4
|
+
status?: "idle" | "pass" | "fail" | "skip" | "running";
|
|
5
|
+
logs?: string[];
|
|
6
|
+
parent?: string;
|
|
7
|
+
id: string;
|
|
8
|
+
type: "test" | "suite";
|
|
9
|
+
only?: boolean;
|
|
10
|
+
skip?: boolean;
|
|
11
|
+
}
|
|
2
12
|
interface TestListProps {
|
|
3
|
-
runTest: (
|
|
4
|
-
tests:
|
|
13
|
+
runTest: (id: string) => Promise<void>;
|
|
14
|
+
tests: Test[];
|
|
5
15
|
}
|
|
6
|
-
export declare const TestList: ({
|
|
16
|
+
export declare const TestList: ({ tests, runTest }: TestListProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
17
|
export {};
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
interface Test {
|
|
2
|
+
name: string;
|
|
3
|
+
depth: number;
|
|
4
|
+
status?: "idle" | "pass" | "fail" | "skip" | "running";
|
|
5
|
+
logs?: string[];
|
|
6
|
+
id: string;
|
|
7
|
+
parent?: string;
|
|
8
|
+
type: "test" | "suite";
|
|
9
|
+
only?: boolean;
|
|
10
|
+
skip?: boolean;
|
|
11
|
+
}
|
|
2
12
|
interface TestListItemProps {
|
|
3
|
-
node:
|
|
13
|
+
node: Test;
|
|
4
14
|
depth: number;
|
|
5
|
-
|
|
6
|
-
runTest: (i:
|
|
15
|
+
id: string;
|
|
16
|
+
runTest: (i: string) => void;
|
|
7
17
|
}
|
|
8
|
-
export declare const statusStyles: (node:
|
|
18
|
+
export declare const statusStyles: (node: Test) => {
|
|
9
19
|
item: {
|
|
10
20
|
background: string;
|
|
11
21
|
};
|
|
@@ -25,5 +35,5 @@ export declare const assertStyles: (text: string) => {
|
|
|
25
35
|
color?: undefined;
|
|
26
36
|
fontWeight?: undefined;
|
|
27
37
|
};
|
|
28
|
-
export declare const TestListItem: ({ node, depth,
|
|
38
|
+
export declare const TestListItem: ({ node, depth, id, runTest, }: TestListItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
29
39
|
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface Test {
|
|
2
|
+
name: string;
|
|
3
|
+
depth: number;
|
|
4
|
+
status?: "idle" | "pass" | "fail" | "skip" | "running";
|
|
5
|
+
logs?: string[];
|
|
6
|
+
id: string;
|
|
7
|
+
parent?: string;
|
|
8
|
+
type: "test" | "suite";
|
|
9
|
+
}
|
|
10
|
+
export type Node = Test & {
|
|
11
|
+
childrenNodes?: Node[];
|
|
12
|
+
};
|
|
13
|
+
export declare const buildTreeFromHandlers: (handlers: Test[]) => Node[];
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("fs"),o=require("path");function r(){return{name:"remove-mock-sw",apply:"build",closeBundle(){try{e.rmSync(o.resolve("dist/mock-sw.js")),console.log("🧹 Removed mock-sw.js from build")}catch{console.log("🧹 No mock-sw.js found in build")}}}}exports.removeMockServiceWorker=r;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { removeMockServiceWorker } from './plugin/removeMockServiceWorker';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { rmSync as o } from "fs";
|
|
2
|
+
import { resolve as e } from "path";
|
|
3
|
+
function c() {
|
|
4
|
+
return {
|
|
5
|
+
name: "remove-mock-sw",
|
|
6
|
+
apply: "build",
|
|
7
|
+
closeBundle() {
|
|
8
|
+
try {
|
|
9
|
+
o(e("dist/mock-sw.js")), console.log("🧹 Removed mock-sw.js from build");
|
|
10
|
+
} catch {
|
|
11
|
+
console.log("🧹 No mock-sw.js found in build");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
c as removeMockServiceWorker
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twd-js",
|
|
3
|
-
"version": "0.
|
|
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,8 +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
|
+
},
|
|
27
|
+
"./runner": {
|
|
28
|
+
"types": "./dist/runner.d.ts",
|
|
29
|
+
"import": "./dist/runner.es.js",
|
|
30
|
+
"require": "./dist/runner.cjs.js"
|
|
31
|
+
},
|
|
32
|
+
"./vite-plugin": {
|
|
33
|
+
"types": "./dist/vite-plugin.d.ts",
|
|
34
|
+
"import": "./dist/vite-plugin.es.js",
|
|
35
|
+
"require": "./dist/vite-plugin.cjs.js"
|
|
36
|
+
},
|
|
37
|
+
"./runner-ci": {
|
|
38
|
+
"types": "./dist/runner-ci.d.ts",
|
|
39
|
+
"import": "./dist/runner-ci.es.js",
|
|
40
|
+
"require": "./dist/runner-ci.cjs.js"
|
|
26
41
|
}
|
|
27
42
|
},
|
|
28
43
|
"files": [
|
|
@@ -73,5 +88,8 @@
|
|
|
73
88
|
"mock-service-worker",
|
|
74
89
|
"frontend-testing",
|
|
75
90
|
"typescript"
|
|
76
|
-
]
|
|
77
|
-
|
|
91
|
+
],
|
|
92
|
+
"dependencies": {
|
|
93
|
+
"chalk": "^5.6.2"
|
|
94
|
+
}
|
|
95
|
+
}
|