@lytjs/test-utils 4.1.0 → 5.0.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/README.md +299 -0
- package/dist/index.cjs +1 -7
- package/dist/index.mjs +1 -7
- package/dist/types/index.d.ts +62 -84
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
# @lytjs/test-utils
|
|
2
|
+
|
|
3
|
+
Lyt.js 统一测试框架 -- 轻量级测试运行器和断言库,纯原生实现,零外部依赖。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lytjs/test-utils --save-dev
|
|
9
|
+
|
|
10
|
+
# 或使用 pnpm
|
|
11
|
+
pnpm add @lytjs/test-utils -D
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 特性
|
|
15
|
+
|
|
16
|
+
- 轻量级测试运行器(describe/it/test/skip)
|
|
17
|
+
- 链式断言库(expect + .not 取反)
|
|
18
|
+
- 生命周期钩子(beforeEach/afterEach)
|
|
19
|
+
- 异步测试支持
|
|
20
|
+
- 彩色终端输出
|
|
21
|
+
- 失败日志自动保存
|
|
22
|
+
- 零外部依赖
|
|
23
|
+
|
|
24
|
+
## 快速开始
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { describe, it, expect, runAll } from '@lytjs/test-utils'
|
|
28
|
+
|
|
29
|
+
describe('我的模块', () => {
|
|
30
|
+
it('应该正常工作', () => {
|
|
31
|
+
expect(1 + 1).toBe(2)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('应该支持深度比较', () => {
|
|
35
|
+
expect({ a: 1, b: 2 }).toEqual({ a: 1, b: 2 })
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('应该支持取反断言', () => {
|
|
39
|
+
expect(null).not.toBeTruthy()
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
runAll()
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## API 参考
|
|
47
|
+
|
|
48
|
+
### describe(name, fn)
|
|
49
|
+
|
|
50
|
+
定义测试套件。
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { describe } from '@lytjs/test-utils'
|
|
54
|
+
|
|
55
|
+
describe('数学运算', () => {
|
|
56
|
+
// 在此注册测试用例
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### it(name, fn) / test(name, fn)
|
|
61
|
+
|
|
62
|
+
注册测试用例。`test` 是 `it` 的别名。
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { it, test } from '@lytjs/test-utils'
|
|
66
|
+
|
|
67
|
+
it('加法运算', () => {
|
|
68
|
+
expect(1 + 1).toBe(2)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
// test 是 it 的别名
|
|
72
|
+
test('减法运算', () => {
|
|
73
|
+
expect(3 - 1).toBe(2)
|
|
74
|
+
})
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### skip(name, fn)
|
|
78
|
+
|
|
79
|
+
跳过测试用例(不会执行)。
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { skip } from '@lytjs/test-utils'
|
|
83
|
+
|
|
84
|
+
skip('待实现的测试', () => {
|
|
85
|
+
expect(true).toBe(false)
|
|
86
|
+
})
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### beforeEach(fn) / afterEach(fn)
|
|
90
|
+
|
|
91
|
+
注册前置/后置钩子,在每个测试用例执行前/后调用。
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { describe, it, beforeEach, afterEach, expect } from '@lytjs/test-utils'
|
|
95
|
+
|
|
96
|
+
let counter = 0
|
|
97
|
+
|
|
98
|
+
describe('计数器', () => {
|
|
99
|
+
beforeEach(() => {
|
|
100
|
+
counter = 0
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
afterEach(() => {
|
|
104
|
+
counter = -1
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('初始值为 0', () => {
|
|
108
|
+
expect(counter).toBe(0)
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### expect(value)
|
|
114
|
+
|
|
115
|
+
创建断言对象,支持链式调用。
|
|
116
|
+
|
|
117
|
+
#### 断言方法
|
|
118
|
+
|
|
119
|
+
| 方法 | 说明 |
|
|
120
|
+
|------|------|
|
|
121
|
+
| `toBe(expected)` | 严格相等 (`===`) |
|
|
122
|
+
| `toEqual(expected)` | 深度相等 |
|
|
123
|
+
| `toBeTruthy()` | 断言为真值 |
|
|
124
|
+
| `toBeFalsy()` | 断言为假值 |
|
|
125
|
+
| `toBeNull()` | 断言为 null |
|
|
126
|
+
| `toBeUndefined()` | 断言为 undefined |
|
|
127
|
+
| `toBeDefined()` | 断言已定义(非 undefined) |
|
|
128
|
+
| `toThrow(message?)` | 断言函数抛出异常 |
|
|
129
|
+
| `toContain(item)` | 断言数组/字符串包含指定项 |
|
|
130
|
+
| `toBeGreaterThan(n)` | 断言数值大于 n |
|
|
131
|
+
| `toBeLessThan(n)` | 断言数值小于 n |
|
|
132
|
+
| `toBeGreaterThanOrEqual(n)` | 断言数值大于等于 n |
|
|
133
|
+
| `toBeLessThanOrEqual(n)` | 断言数值小于等于 n |
|
|
134
|
+
| `toHaveLength(n)` | 断言数组/字符串长度为 n |
|
|
135
|
+
|
|
136
|
+
#### 取反断言
|
|
137
|
+
|
|
138
|
+
所有断言方法均可通过 `.not` 取反:
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
expect(1).not.toBe(2)
|
|
142
|
+
expect([1, 2]).not.toContain(3)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### runAll()
|
|
146
|
+
|
|
147
|
+
运行所有已注册的测试套件,输出格式化报告。
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { runAll } from '@lytjs/test-utils'
|
|
151
|
+
|
|
152
|
+
const result = await runAll()
|
|
153
|
+
// result: { total, passed, failed, skipped, results }
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### waitFor(ms)
|
|
157
|
+
|
|
158
|
+
等待指定毫秒数,用于异步测试。
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
import { waitFor } from '@lytjs/test-utils'
|
|
162
|
+
|
|
163
|
+
it('异步操作', async () => {
|
|
164
|
+
await waitFor(100)
|
|
165
|
+
expect(true).toBe(true)
|
|
166
|
+
})
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### deepEqual(a, b)
|
|
170
|
+
|
|
171
|
+
深度比较两个值是否相等。
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
import { deepEqual } from '@lytjs/test-utils'
|
|
175
|
+
|
|
176
|
+
const result = deepEqual({ a: [1, 2] }, { a: [1, 2] })
|
|
177
|
+
// result: true
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## 示例
|
|
181
|
+
|
|
182
|
+
### 基础测试
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
import { describe, it, expect, runAll } from '@lytjs/test-utils'
|
|
186
|
+
|
|
187
|
+
describe('字符串操作', () => {
|
|
188
|
+
it('应该正确拼接字符串', () => {
|
|
189
|
+
const result = 'hello' + ' ' + 'world'
|
|
190
|
+
expect(result).toBe('hello world')
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
it('应该正确获取长度', () => {
|
|
194
|
+
expect('hello').toHaveLength(5)
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
it('应该包含子串', () => {
|
|
198
|
+
expect('hello world').toContain('world')
|
|
199
|
+
})
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
runAll()
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### 异步测试
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
import { describe, it, expect, waitFor, runAll } from '@lytjs/test-utils'
|
|
209
|
+
|
|
210
|
+
describe('异步操作', () => {
|
|
211
|
+
it('应该支持 async/await', async () => {
|
|
212
|
+
await waitFor(50)
|
|
213
|
+
expect(true).toBe(true)
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
it('应该处理 Promise', async () => {
|
|
217
|
+
const promise = Promise.resolve(42)
|
|
218
|
+
const result = await promise
|
|
219
|
+
expect(result).toBe(42)
|
|
220
|
+
})
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
runAll()
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### 错误处理测试
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
import { describe, it, expect, runAll } from '@lytjs/test-utils'
|
|
230
|
+
|
|
231
|
+
describe('错误处理', () => {
|
|
232
|
+
it('应该抛出异常', () => {
|
|
233
|
+
expect(() => {
|
|
234
|
+
throw new Error('test error')
|
|
235
|
+
}).toThrow('test error')
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
it('应该断言不抛出异常', () => {
|
|
239
|
+
expect(() => {
|
|
240
|
+
// 不抛出异常
|
|
241
|
+
}).not.toThrow()
|
|
242
|
+
})
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
runAll()
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### 数值比较
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
import { describe, it, expect, runAll } from '@lytjs/test-utils'
|
|
252
|
+
|
|
253
|
+
describe('数值比较', () => {
|
|
254
|
+
it('应该支持大于比较', () => {
|
|
255
|
+
expect(10).toBeGreaterThan(5)
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
it('应该支持小于比较', () => {
|
|
259
|
+
expect(3).toBeLessThan(8)
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
it('应该支持大于等于', () => {
|
|
263
|
+
expect(5).toBeGreaterThanOrEqual(5)
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
it('应该支持小于等于', () => {
|
|
267
|
+
expect(5).toBeLessThanOrEqual(5)
|
|
268
|
+
})
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
runAll()
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## 运行输出
|
|
275
|
+
|
|
276
|
+
运行 `runAll()` 后,终端会输出彩色格式化的测试报告:
|
|
277
|
+
|
|
278
|
+
```
|
|
279
|
+
=== Lyt.js 测试运行器 ===
|
|
280
|
+
|
|
281
|
+
我的模块
|
|
282
|
+
[PASS] 应该正常工作
|
|
283
|
+
[PASS] 应该支持深度比较
|
|
284
|
+
|
|
285
|
+
=== 测试结果 ===
|
|
286
|
+
总计: 2
|
|
287
|
+
通过: 2
|
|
288
|
+
|
|
289
|
+
所有测试通过!
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## 兼容性
|
|
293
|
+
|
|
294
|
+
- Node.js >= 18.0.0
|
|
295
|
+
- TypeScript 5.0+
|
|
296
|
+
|
|
297
|
+
## License
|
|
298
|
+
|
|
299
|
+
MIT
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
${n.bold}${n.cyan}=== Lyt.js \u6D4B\u8BD5\u8FD0\u884C\u5668 ===${n.reset}
|
|
3
|
-
`);for(let l of w){console.log(`${n.bold}${l.name}${n.reset}`);for(let h of l.tests){t++;let O=performance.now();if(l.beforeEachFn)for(let o of l.beforeEachFn)try{o()}catch(b){console.warn(` ${n.yellow}[WARN] beforeEach \u51FA\u9519: ${b.message}${n.reset}`)}let f="passed",c;try{let o=h.fn();o instanceof Promise&&await o}catch(o){o instanceof g?(f="skipped",i++):(f="failed",r++,c=o,u.push(`Suite: ${l.name}, Test: ${h.name}, Error: ${(c==null?void 0:c.message)||"Unknown error"}`))}let m=performance.now()-O;if(l.afterEachFn)for(let o of l.afterEachFn)try{o()}catch(b){console.warn(` ${n.yellow}[WARN] afterEach \u51FA\u9519: ${b.message}${n.reset}`)}f==="passed"&&e++;let P={name:h.name,suite:l.name,status:f,error:c,duration:m};s.push(P);let y=m<1?"":` ${n.gray}(${m.toFixed(1)}ms)${n.reset}`;f==="passed"?console.log(` ${n.green}[PASS]${n.reset} ${h.name}${y}`):f==="skipped"?console.log(` ${n.yellow}[SKIP]${n.reset} ${h.name}${y}`):(console.log(` ${n.red}[FAIL]${n.reset} ${h.name}${y}`),c&&console.log(` ${n.red}${c.message}${n.reset}`))}console.log("")}let E=F.join(process.cwd(),"failed-tests.log");return S.writeFileSync(E,u.join(`
|
|
4
|
-
`),"utf8"),console.log(`\u5931\u8D25\u7684\u6D4B\u8BD5\u5DF2\u4FDD\u5B58\u5230 ${E}, \u5171 ${u.length} \u4E2A\u5931\u8D25
|
|
5
|
-
`),console.log(`${n.bold}=== \u6D4B\u8BD5\u7ED3\u679C ===${n.reset}`),console.log(` \u603B\u8BA1: ${t}`),console.log(` ${n.green}\u901A\u8FC7: ${e}${n.reset}`),r>0&&console.log(` ${n.red}\u5931\u8D25: ${r}${n.reset}`),i>0&&console.log(` ${n.yellow}\u8DF3\u8FC7: ${i}${n.reset}`),console.log(""),console.log(r===0?`${n.green}${n.bold}\u6240\u6709\u6D4B\u8BD5\u901A\u8FC7!${n.reset}
|
|
6
|
-
`:`${n.red}${n.bold}\u5B58\u5728\u5931\u8D25\u7684\u6D4B\u8BD5!${n.reset}
|
|
7
|
-
`),w.length=0,{total:t,passed:e,failed:r,skipped:i,results:s}}0&&(module.exports={Assertion,afterEach,beforeEach,deepEqual,describe,expect,it,runAll,skip,test,waitFor});
|
|
1
|
+
"use strict";var d=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var b=(i,t)=>{for(var e in t)d(i,e,{get:t[e],enumerable:!0})},_=(i,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of $(t))!y.call(i,s)&&s!==e&&d(i,s,{get:()=>t[s],enumerable:!(a=m(t,s))||a.enumerable});return i};var v=i=>_(d({},"__esModule",{value:!0}),i);var B={};b(B,{Assertion:()=>l,afterEach:()=>T,beforeEach:()=>k,deepEqual:()=>u,describe:()=>E,expect:()=>O,it:()=>g,runAll:()=>j,skip:()=>x,test:()=>w,waitFor:()=>F});module.exports=v(B);var p=[],o=null;function E(i,t){let e={name:i,tests:[],beforeEachFn:[],afterEachFn:[]},a=o;o=e,t(),o=a,p.push(e)}function g(i,t){if(!o)throw new Error("it() must be called inside describe()");o.tests.push({name:i,fn:t})}var w=g;function x(i,t){if(!o)throw new Error("skip() must be called inside describe()");o.tests.push({name:i,fn:t,skipped:!0})}function k(i){var t;(t=o==null?void 0:o.beforeEachFn)==null||t.push(i)}function T(i){var t;(t=o==null?void 0:o.afterEachFn)==null||t.push(i)}function O(i){return new l(i)}function u(i,t){if(Object.is(i,t))return!0;if(i===null||t===null||typeof i!=typeof t)return!1;if(typeof i=="object"){let e=Object.keys(i),a=Object.keys(t);if(e.length!==a.length)return!1;for(let s of e)if(!Object.prototype.hasOwnProperty.call(t,s)||!u(i[s],t[s]))return!1;return!0}return!1}function F(i){return new Promise(t=>setTimeout(t,i))}async function j(){let i=[],t=0,e=0,a=0;for(let s of p)for(let n of s.tests){if(n.skipped){a++,i.push({name:n.name,suite:s.name,status:"skipped",duration:0}),console.log(` \x1B[33m\u2298 SKIP\x1B[0m ${s.name} > ${n.name}`);continue}let r=Date.now();try{if(s.beforeEachFn)for(let f of s.beforeEachFn)f();let h=n.fn();if(h instanceof Promise&&await h,s.afterEachFn)for(let f of s.afterEachFn)f();let c=Date.now()-r;t++,i.push({name:n.name,suite:s.name,status:"passed",duration:c}),console.log(` \x1B[32m\u2713 PASS\x1B[0m ${s.name} > ${n.name} (${c}ms)`)}catch(h){let c=Date.now()-r;e++,i.push({name:n.name,suite:s.name,status:"failed",error:h,duration:c}),console.log(` \x1B[31m\u2717 FAIL\x1B[0m ${s.name} > ${n.name}`),console.log(` \x1B[31m${h.message}\x1B[0m`)}}return p.length=0,console.log(""),console.log(`--- \u6D4B\u8BD5\u7ED3\u679C: ${t} \u901A\u8FC7, ${e} \u5931\u8D25, ${a} \u8DF3\u8FC7, \u5171 ${t+e+a} \u4E2A ---`),console.log(""),{total:t+e+a,passed:t,failed:e,skipped:a,results:i}}var l=class{constructor(t){this.negated=!1;this.actual=t}get not(){return this.negated=!this.negated,this}toBe(t){let e=this.negated?!Object.is(this.actual,t):Object.is(this.actual,t);this._assert(e,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u7B49\u4E8E ${this._fmt(t)}`)}toEqual(t){let e=this.negated?!u(this.actual,t):u(this.actual,t);this._assert(e,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u6DF1\u5EA6\u7B49\u4E8E ${this._fmt(t)}`)}toBeTruthy(){let t=this.negated?!this.actual:!!this.actual;this._assert(t,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u4E3A\u771F\u503C`)}toBeFalsy(){let t=this.negated?!!this.actual:!this.actual;this._assert(t,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u4E3A\u5047\u503C`)}toBeNull(){let t=this.negated?this.actual!==null:this.actual===null;this._assert(t,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u4E3A null`)}toBeUndefined(){let t=this.negated?this.actual!==void 0:this.actual===void 0;this._assert(t,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u4E3A undefined`)}toBeDefined(){let t=this.negated?this.actual===void 0:this.actual!==void 0;this._assert(t,`\u671F\u671B\u503C ${this.negated?"\u4E0D":""}\u5DF2\u5B9A\u4E49`)}toThrow(t){let e=!1,a="";try{if(typeof this.actual=="function")this.actual();else throw new Error("toThrow() \u7684\u5B9E\u9645\u503C\u5FC5\u987B\u662F\u51FD\u6570")}catch(n){e=!0,a=n.message||String(n)}let s=this.negated?!e:e;s&&e&&t&&!this.negated&&(s=a.includes(t)),this._assert(s,`\u671F\u671B\u51FD\u6570${this.negated?"\u4E0D":""}\u629B\u51FA\u5F02\u5E38${t?` (\u5305\u542B "${t}")`:""}`)}toContain(t){let e;typeof this.actual=="string"?e=this.actual.includes(t):Array.isArray(this.actual)?e=this.actual.some(a=>u(a,t)):e=!1,this.negated&&(e=!e),this._assert(e,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u5305\u542B ${this._fmt(t)}`)}toBeGreaterThan(t){let e=this.negated?!(this.actual>t):this.actual>t;this._assert(e,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u5927\u4E8E ${t}`)}toBeLessThan(t){let e=this.negated?!(this.actual<t):this.actual<t;this._assert(e,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u5C0F\u4E8E ${t}`)}toBeGreaterThanOrEqual(t){let e=this.negated?!(this.actual>=t):this.actual>=t;this._assert(e,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u5927\u4E8E\u7B49\u4E8E ${t}`)}toBeLessThanOrEqual(t){let e=this.negated?!(this.actual<=t):this.actual<=t;this._assert(e,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u5C0F\u4E8E\u7B49\u4E8E ${t}`)}toHaveLength(t){var s;let e=(s=this.actual)==null?void 0:s.length,a=this.negated?e!==t:e===t;this._assert(a,`\u671F\u671B\u957F\u5EA6\u4E3A ${t}\uFF0C\u5B9E\u9645\u4E3A ${e}`)}toBeInstanceOf(t){let e=this.negated?!(this.actual instanceof t):this.actual instanceof t;this._assert(e,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u662F ${t.name} \u7684\u5B9E\u4F8B`)}toHaveProperty(t,e){let a=t.split("."),s=this.actual,n=!0;for(let r of a){if(s==null||typeof s!="object"){n=!1;break}s=s[r]}if(e!==void 0){let r=this.negated?!(n&&Object.is(s,e)):n&&Object.is(s,e);this._assert(r,`\u671F\u671B\u5BF9\u8C61${this.negated?"\u4E0D":""}\u5305\u542B\u5C5E\u6027 "${t}" \u503C\u4E3A ${this._fmt(e)}`)}else{let r=this.negated?!n:n;this._assert(r,`\u671F\u671B\u5BF9\u8C61${this.negated?"\u4E0D":""}\u5305\u542B\u5C5E\u6027 "${t}"`)}}_assert(t,e){if(!t)throw new Error(e)}_fmt(t){if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string")return`"${t}"`;if(typeof t=="function")return"[Function]";if(Array.isArray(t))try{return JSON.stringify(t)}catch(e){return"[Array]"}if(typeof t=="object")try{return JSON.stringify(t)}catch(e){return"[Object]"}return String(t)}};0&&(module.exports={Assertion,afterEach,beforeEach,deepEqual,describe,expect,it,runAll,skip,test,waitFor});
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
${s.bold}${s.cyan}=== Lyt.js \u6D4B\u8BD5\u8FD0\u884C\u5668 ===${s.reset}
|
|
3
|
-
`);for(let l of y){console.log(`${s.bold}${l.name}${s.reset}`);for(let h of l.tests){t++;let T=performance.now();if(l.beforeEachFn)for(let o of l.beforeEachFn)try{o()}catch(m){console.warn(` ${s.yellow}[WARN] beforeEach \u51FA\u9519: ${m.message}${s.reset}`)}let f="passed",c;try{let o=h.fn();o instanceof Promise&&await o}catch(o){o instanceof $?(f="skipped",r++):(f="failed",i++,c=o,u.push(`Suite: ${l.name}, Test: ${h.name}, Error: ${(c==null?void 0:c.message)||"Unknown error"}`))}let g=performance.now()-T;if(l.afterEachFn)for(let o of l.afterEachFn)try{o()}catch(m){console.warn(` ${s.yellow}[WARN] afterEach \u51FA\u9519: ${m.message}${s.reset}`)}f==="passed"&&e++;let S={name:h.name,suite:l.name,status:f,error:c,duration:g};n.push(S);let p=g<1?"":` ${s.gray}(${g.toFixed(1)}ms)${s.reset}`;f==="passed"?console.log(` ${s.green}[PASS]${s.reset} ${h.name}${p}`):f==="skipped"?console.log(` ${s.yellow}[SKIP]${s.reset} ${h.name}${p}`):(console.log(` ${s.red}[FAIL]${s.reset} ${h.name}${p}`),c&&console.log(` ${s.red}${c.message}${s.reset}`))}console.log("")}let v=_.join(process.cwd(),"failed-tests.log");return E.writeFileSync(v,u.join(`
|
|
4
|
-
`),"utf8"),console.log(`\u5931\u8D25\u7684\u6D4B\u8BD5\u5DF2\u4FDD\u5B58\u5230 ${v}, \u5171 ${u.length} \u4E2A\u5931\u8D25
|
|
5
|
-
`),console.log(`${s.bold}=== \u6D4B\u8BD5\u7ED3\u679C ===${s.reset}`),console.log(` \u603B\u8BA1: ${t}`),console.log(` ${s.green}\u901A\u8FC7: ${e}${s.reset}`),i>0&&console.log(` ${s.red}\u5931\u8D25: ${i}${s.reset}`),r>0&&console.log(` ${s.yellow}\u8DF3\u8FC7: ${r}${s.reset}`),console.log(""),console.log(i===0?`${s.green}${s.bold}\u6240\u6709\u6D4B\u8BD5\u901A\u8FC7!${s.reset}
|
|
6
|
-
`:`${s.red}${s.bold}\u5B58\u5728\u5931\u8D25\u7684\u6D4B\u8BD5!${s.reset}
|
|
7
|
-
`),y.length=0,{total:t,passed:e,failed:i,skipped:r,results:n}}export{b as Assertion,A as afterEach,j as beforeEach,d as deepEqual,k as describe,B as expect,F as it,x as runAll,P as skip,O as test,R as waitFor};
|
|
1
|
+
var f=[],o=null;function g(i,t){let e={name:i,tests:[],beforeEachFn:[],afterEachFn:[]},a=o;o=e,t(),o=a,f.push(e)}function p(i,t){if(!o)throw new Error("it() must be called inside describe()");o.tests.push({name:i,fn:t})}var m=p;function $(i,t){if(!o)throw new Error("skip() must be called inside describe()");o.tests.push({name:i,fn:t,skipped:!0})}function y(i){var t;(t=o==null?void 0:o.beforeEachFn)==null||t.push(i)}function b(i){var t;(t=o==null?void 0:o.afterEachFn)==null||t.push(i)}function _(i){return new d(i)}function c(i,t){if(Object.is(i,t))return!0;if(i===null||t===null||typeof i!=typeof t)return!1;if(typeof i=="object"){let e=Object.keys(i),a=Object.keys(t);if(e.length!==a.length)return!1;for(let s of e)if(!Object.prototype.hasOwnProperty.call(t,s)||!c(i[s],t[s]))return!1;return!0}return!1}function v(i){return new Promise(t=>setTimeout(t,i))}async function E(){let i=[],t=0,e=0,a=0;for(let s of f)for(let n of s.tests){if(n.skipped){a++,i.push({name:n.name,suite:s.name,status:"skipped",duration:0}),console.log(` \x1B[33m\u2298 SKIP\x1B[0m ${s.name} > ${n.name}`);continue}let r=Date.now();try{if(s.beforeEachFn)for(let l of s.beforeEachFn)l();let h=n.fn();if(h instanceof Promise&&await h,s.afterEachFn)for(let l of s.afterEachFn)l();let u=Date.now()-r;t++,i.push({name:n.name,suite:s.name,status:"passed",duration:u}),console.log(` \x1B[32m\u2713 PASS\x1B[0m ${s.name} > ${n.name} (${u}ms)`)}catch(h){let u=Date.now()-r;e++,i.push({name:n.name,suite:s.name,status:"failed",error:h,duration:u}),console.log(` \x1B[31m\u2717 FAIL\x1B[0m ${s.name} > ${n.name}`),console.log(` \x1B[31m${h.message}\x1B[0m`)}}return f.length=0,console.log(""),console.log(`--- \u6D4B\u8BD5\u7ED3\u679C: ${t} \u901A\u8FC7, ${e} \u5931\u8D25, ${a} \u8DF3\u8FC7, \u5171 ${t+e+a} \u4E2A ---`),console.log(""),{total:t+e+a,passed:t,failed:e,skipped:a,results:i}}var d=class{constructor(t){this.negated=!1;this.actual=t}get not(){return this.negated=!this.negated,this}toBe(t){let e=this.negated?!Object.is(this.actual,t):Object.is(this.actual,t);this._assert(e,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u7B49\u4E8E ${this._fmt(t)}`)}toEqual(t){let e=this.negated?!c(this.actual,t):c(this.actual,t);this._assert(e,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u6DF1\u5EA6\u7B49\u4E8E ${this._fmt(t)}`)}toBeTruthy(){let t=this.negated?!this.actual:!!this.actual;this._assert(t,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u4E3A\u771F\u503C`)}toBeFalsy(){let t=this.negated?!!this.actual:!this.actual;this._assert(t,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u4E3A\u5047\u503C`)}toBeNull(){let t=this.negated?this.actual!==null:this.actual===null;this._assert(t,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u4E3A null`)}toBeUndefined(){let t=this.negated?this.actual!==void 0:this.actual===void 0;this._assert(t,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u4E3A undefined`)}toBeDefined(){let t=this.negated?this.actual===void 0:this.actual!==void 0;this._assert(t,`\u671F\u671B\u503C ${this.negated?"\u4E0D":""}\u5DF2\u5B9A\u4E49`)}toThrow(t){let e=!1,a="";try{if(typeof this.actual=="function")this.actual();else throw new Error("toThrow() \u7684\u5B9E\u9645\u503C\u5FC5\u987B\u662F\u51FD\u6570")}catch(n){e=!0,a=n.message||String(n)}let s=this.negated?!e:e;s&&e&&t&&!this.negated&&(s=a.includes(t)),this._assert(s,`\u671F\u671B\u51FD\u6570${this.negated?"\u4E0D":""}\u629B\u51FA\u5F02\u5E38${t?` (\u5305\u542B "${t}")`:""}`)}toContain(t){let e;typeof this.actual=="string"?e=this.actual.includes(t):Array.isArray(this.actual)?e=this.actual.some(a=>c(a,t)):e=!1,this.negated&&(e=!e),this._assert(e,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u5305\u542B ${this._fmt(t)}`)}toBeGreaterThan(t){let e=this.negated?!(this.actual>t):this.actual>t;this._assert(e,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u5927\u4E8E ${t}`)}toBeLessThan(t){let e=this.negated?!(this.actual<t):this.actual<t;this._assert(e,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u5C0F\u4E8E ${t}`)}toBeGreaterThanOrEqual(t){let e=this.negated?!(this.actual>=t):this.actual>=t;this._assert(e,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u5927\u4E8E\u7B49\u4E8E ${t}`)}toBeLessThanOrEqual(t){let e=this.negated?!(this.actual<=t):this.actual<=t;this._assert(e,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u5C0F\u4E8E\u7B49\u4E8E ${t}`)}toHaveLength(t){var s;let e=(s=this.actual)==null?void 0:s.length,a=this.negated?e!==t:e===t;this._assert(a,`\u671F\u671B\u957F\u5EA6\u4E3A ${t}\uFF0C\u5B9E\u9645\u4E3A ${e}`)}toBeInstanceOf(t){let e=this.negated?!(this.actual instanceof t):this.actual instanceof t;this._assert(e,`\u671F\u671B ${this._fmt(this.actual)} ${this.negated?"\u4E0D":""}\u662F ${t.name} \u7684\u5B9E\u4F8B`)}toHaveProperty(t,e){let a=t.split("."),s=this.actual,n=!0;for(let r of a){if(s==null||typeof s!="object"){n=!1;break}s=s[r]}if(e!==void 0){let r=this.negated?!(n&&Object.is(s,e)):n&&Object.is(s,e);this._assert(r,`\u671F\u671B\u5BF9\u8C61${this.negated?"\u4E0D":""}\u5305\u542B\u5C5E\u6027 "${t}" \u503C\u4E3A ${this._fmt(e)}`)}else{let r=this.negated?!n:n;this._assert(r,`\u671F\u671B\u5BF9\u8C61${this.negated?"\u4E0D":""}\u5305\u542B\u5C5E\u6027 "${t}"`)}}_assert(t,e){if(!t)throw new Error(e)}_fmt(t){if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string")return`"${t}"`;if(typeof t=="function")return"[Function]";if(Array.isArray(t))try{return JSON.stringify(t)}catch(e){return"[Array]"}if(typeof t=="object")try{return JSON.stringify(t)}catch(e){return"[Object]"}return String(t)}};export{d as Assertion,b as afterEach,y as beforeEach,c as deepEqual,g as describe,_ as expect,p as it,E as runAll,$ as skip,m as test,v as waitFor};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,106 +1,66 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Lyt.js 统一测试框架
|
|
3
|
+
*
|
|
4
|
+
* 自定义轻量级测试框架,用于 Node.js 环境下运行测试。
|
|
5
|
+
* 由 test-runner.ts 统一调度,通过 globalThis 挂载到全局。
|
|
6
|
+
*
|
|
7
|
+
* 使用方式:
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { describe, it, expect } from '@lytjs/test-utils'
|
|
10
|
+
*
|
|
11
|
+
* describe('我的模块', () => {
|
|
12
|
+
* it('应该正常工作', () => {
|
|
13
|
+
* expect(1 + 1).toBe(2)
|
|
14
|
+
* })
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export interface TestCase {
|
|
2
19
|
name: string;
|
|
3
20
|
fn: () => void | Promise<void>;
|
|
21
|
+
skipped?: boolean;
|
|
4
22
|
}
|
|
5
|
-
interface TestResult {
|
|
23
|
+
export interface TestResult {
|
|
6
24
|
name: string;
|
|
7
25
|
suite: string;
|
|
8
26
|
status: 'passed' | 'failed' | 'skipped';
|
|
9
27
|
error?: Error;
|
|
10
28
|
duration: number;
|
|
11
29
|
}
|
|
12
|
-
interface TestSuite {
|
|
30
|
+
export interface TestSuite {
|
|
13
31
|
name: string;
|
|
14
32
|
tests: TestCase[];
|
|
15
33
|
beforeEachFn?: (() => void)[];
|
|
16
34
|
afterEachFn?: (() => void)[];
|
|
17
35
|
}
|
|
18
36
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @param name 测试套件名称
|
|
22
|
-
* @param fn 定义函数,内部使用 it/test 注册测试用例
|
|
37
|
+
* 注册一个测试套件
|
|
23
38
|
*/
|
|
24
|
-
declare function describe(name: string, fn: () => void): void;
|
|
39
|
+
export declare function describe(name: string, fn: () => void): void;
|
|
25
40
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @param name 测试名称
|
|
29
|
-
* @param fn 测试函数
|
|
41
|
+
* 注册一个测试用例
|
|
30
42
|
*/
|
|
31
|
-
declare function it(name: string, fn: () => void | Promise<void>): void;
|
|
32
|
-
/** it 的别名 */
|
|
33
|
-
declare function test(name: string, fn: () => void | Promise<void>): void;
|
|
43
|
+
export declare function it(name: string, fn: () => void | Promise<void>): void;
|
|
34
44
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* @param name 测试名称
|
|
38
|
-
* @param fn 测试函数(不会执行)
|
|
45
|
+
* test 是 it 的别名
|
|
39
46
|
*/
|
|
40
|
-
declare
|
|
47
|
+
export declare const test: typeof it;
|
|
41
48
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* @param fn 每个测试用例执行前调用的函数
|
|
49
|
+
* 跳过一个测试用例
|
|
45
50
|
*/
|
|
46
|
-
declare function
|
|
51
|
+
export declare function skip(name: string, fn: () => void | Promise<void>): void;
|
|
47
52
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @param fn 每个测试用例执行后调用的函数
|
|
53
|
+
* 注册 beforeEach 钩子
|
|
51
54
|
*/
|
|
52
|
-
declare function
|
|
55
|
+
export declare function beforeEach(fn: () => void): void;
|
|
53
56
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* 支持链式调用和 .not 取反。
|
|
57
|
+
* 注册 afterEach 钩子
|
|
57
58
|
*/
|
|
58
|
-
declare
|
|
59
|
-
private actual;
|
|
60
|
-
private negated;
|
|
61
|
-
constructor(actual: any);
|
|
62
|
-
/** 取反后续断言 */
|
|
63
|
-
get not(): Assertion;
|
|
64
|
-
/** 断言严格相等 (===) */
|
|
65
|
-
toBe(expected: any): void;
|
|
66
|
-
/** 断言深度相等 */
|
|
67
|
-
toEqual(expected: any): void;
|
|
68
|
-
/** 断言为真值 */
|
|
69
|
-
toBeTruthy(): void;
|
|
70
|
-
/** 断言为假值 */
|
|
71
|
-
toBeFalsy(): void;
|
|
72
|
-
/** 断言为 null */
|
|
73
|
-
toBeNull(): void;
|
|
74
|
-
/** 断言为 undefined */
|
|
75
|
-
toBeUndefined(): void;
|
|
76
|
-
/** 断言不为 undefined(即已定义) */
|
|
77
|
-
toBeDefined(): void;
|
|
78
|
-
/** 断言函数抛出异常 */
|
|
79
|
-
toThrow(message?: string): void;
|
|
80
|
-
/** 断言数组/字符串包含指定项 */
|
|
81
|
-
toContain(item: any): void;
|
|
82
|
-
/** 断言数值大于 n */
|
|
83
|
-
toBeGreaterThan(n: number): void;
|
|
84
|
-
/** 断言数值小于 n */
|
|
85
|
-
toBeLessThan(n: number): void;
|
|
86
|
-
/** 断言数值大于等于 n */
|
|
87
|
-
toBeGreaterThanOrEqual(n: number): void;
|
|
88
|
-
/** 断言数值小于等于 n */
|
|
89
|
-
toBeLessThanOrEqual(n: number): void;
|
|
90
|
-
/** 断言数组/字符串长度为 n */
|
|
91
|
-
toHaveLength(n: number): void;
|
|
92
|
-
/** 内部断言方法 */
|
|
93
|
-
private _assert;
|
|
94
|
-
/** 格式化值用于错误消息 */
|
|
95
|
-
private _fmt;
|
|
96
|
-
}
|
|
59
|
+
export declare function afterEach(fn: () => void): void;
|
|
97
60
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* @param value 要断言的值
|
|
101
|
-
* @returns Assertion 实例
|
|
61
|
+
* 创建一个断言对象
|
|
102
62
|
*/
|
|
103
|
-
declare function expect(
|
|
63
|
+
export declare function expect(actual: any): Assertion;
|
|
104
64
|
/**
|
|
105
65
|
* 深度比较两个值
|
|
106
66
|
*
|
|
@@ -108,28 +68,46 @@ declare function expect(value: any): Assertion;
|
|
|
108
68
|
* @param b 第二个值
|
|
109
69
|
* @returns 是否深度相等
|
|
110
70
|
*/
|
|
111
|
-
declare function deepEqual(a: any, b: any): boolean;
|
|
71
|
+
export declare function deepEqual(a: any, b: any): boolean;
|
|
112
72
|
/**
|
|
113
73
|
* 等待指定毫秒数
|
|
114
74
|
*
|
|
115
75
|
* @param ms 等待时间(毫秒)
|
|
116
76
|
* @returns Promise
|
|
117
77
|
*/
|
|
118
|
-
declare function waitFor(ms: number): Promise<void>;
|
|
78
|
+
export declare function waitFor(ms: number): Promise<void>;
|
|
119
79
|
/**
|
|
120
80
|
* 运行所有已注册的测试套件
|
|
121
|
-
*
|
|
122
|
-
* 按注册顺序执行所有 describe 中的测试用例,
|
|
123
|
-
* 收集结果并输出格式化报告。
|
|
124
|
-
*
|
|
125
|
-
* @returns 测试结果汇总
|
|
126
81
|
*/
|
|
127
|
-
declare function runAll(): Promise<{
|
|
82
|
+
export declare function runAll(): Promise<{
|
|
128
83
|
total: number;
|
|
129
84
|
passed: number;
|
|
130
85
|
failed: number;
|
|
131
86
|
skipped: number;
|
|
132
87
|
results: TestResult[];
|
|
133
88
|
}>;
|
|
134
|
-
export
|
|
89
|
+
export declare class Assertion {
|
|
90
|
+
private actual;
|
|
91
|
+
private negated;
|
|
92
|
+
constructor(actual: any);
|
|
93
|
+
get not(): Assertion;
|
|
94
|
+
toBe(expected: any): void;
|
|
95
|
+
toEqual(expected: any): void;
|
|
96
|
+
toBeTruthy(): void;
|
|
97
|
+
toBeFalsy(): void;
|
|
98
|
+
toBeNull(): void;
|
|
99
|
+
toBeUndefined(): void;
|
|
100
|
+
toBeDefined(): void;
|
|
101
|
+
toThrow(message?: string): void;
|
|
102
|
+
toContain(item: any): void;
|
|
103
|
+
toBeGreaterThan(n: number): void;
|
|
104
|
+
toBeLessThan(n: number): void;
|
|
105
|
+
toBeGreaterThanOrEqual(n: number): void;
|
|
106
|
+
toBeLessThanOrEqual(n: number): void;
|
|
107
|
+
toHaveLength(n: number): void;
|
|
108
|
+
toBeInstanceOf(cls: any): void;
|
|
109
|
+
toHaveProperty(path: string, value?: any): void;
|
|
110
|
+
private _assert;
|
|
111
|
+
private _fmt;
|
|
112
|
+
}
|
|
135
113
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lytjs/test-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Lyt.js 测试工具库 - 提供组件挂载、状态模拟和断言辅助等测试工具",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
+
"types": "./dist/types/index.d.ts",
|
|
9
10
|
"import": "./dist/index.mjs",
|
|
10
11
|
"require": "./dist/index.cjs",
|
|
11
12
|
"default": "./dist/index.mjs"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"fileNames":["../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.dom.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.scripthost.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.array.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.error.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.object.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.string.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.full.d.ts","../src/index.ts"],"fileInfos":[{"version":"bcd24271a113971ba9eb71ff8cb01bc6b0f872a85c23fdbe5d93065b375933cd","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"3f88bedbeb09c6f5a6645cb24c7c55f1aa22d19ae96c8e6959cbd8b85a707bc6","signature":false,"impliedFormat":1},{"version":"7fe93b39b810eadd916be8db880dd7f0f7012a5cc6ffb62de8f62a2117fa6f1f","signature":false,"impliedFormat":1},{"version":"bb0074cc08b84a2374af33d8bf044b80851ccc9e719a5e202eacf40db2c31600","signature":false,"impliedFormat":1},{"version":"1a7daebe4f45fb03d9ec53d60008fbf9ac45a697fdc89e4ce218bc94b94f94d6","signature":false,"impliedFormat":1},{"version":"f94b133a3cb14a288803be545ac2683e0d0ff6661bcd37e31aaaec54fc382aed","signature":false,"impliedFormat":1},{"version":"f59d0650799f8782fd74cf73c19223730c6d1b9198671b1c5b3a38e1188b5953","signature":false,"impliedFormat":1},{"version":"8a15b4607d9a499e2dbeed9ec0d3c0d7372c850b2d5f1fb259e8f6d41d468a84","signature":false,"impliedFormat":1},{"version":"26e0fe14baee4e127f4365d1ae0b276f400562e45e19e35fd2d4c296684715e6","signature":false,"impliedFormat":1},{"version":"d6b1eba8496bdd0eed6fc8a685768fe01b2da4a0388b5fe7df558290bffcf32f","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"7f57fc4404ff020bc45b9c620aff2b40f700b95fe31164024c453a5e3c163c54","signature":false,"impliedFormat":1},{"version":"7f57fc4404ff020bc45b9c620aff2b40f700b95fe31164024c453a5e3c163c54","signature":false,"impliedFormat":1},{"version":"2a2de5b9459b3fc44decd9ce6100b72f1b002ef523126c1d3d8b2a4a63d74d78","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"f13f4b465c99041e912db5c44129a94588e1aafee35a50eab51044833f50b4ee","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"eadcffda2aa84802c73938e589b9e58248d74c59cb7fcbca6474e3435ac15504","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"105ba8ff7ba746404fe1a2e189d1d3d2e0eb29a08c18dded791af02f29fb4711","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"00343ca5b2e3d48fa5df1db6e32ea2a59afab09590274a6cccb1dbae82e60c7c","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"ebd9f816d4002697cb2864bea1f0b70a103124e18a8cd9645eeccc09bdf80ab4","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"2c1afac30a01772cd2a9a298a7ce7706b5892e447bb46bdbeef720f7b5da77ad","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"7b0225f483e4fa685625ebe43dd584bb7973bbd84e66a6ba7bbe175ee1048b4f","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"c0a4b8ac6ce74679c1da2b3795296f5896e31c38e888469a8e0f99dc3305de60","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"3084a7b5f569088e0146533a00830e206565de65cae2239509168b11434cd84f","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"c5079c53f0f141a0698faa903e76cb41cd664e3efb01cc17a5c46ec2eb0bef42","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"32cafbc484dea6b0ab62cf8473182bbcb23020d70845b406f80b7526f38ae862","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"fca4cdcb6d6c5ef18a869003d02c9f0fd95df8cfaf6eb431cd3376bc034cad36","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"b93ec88115de9a9dc1b602291b85baf825c85666bf25985cc5f698073892b467","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"f5c06dcc3fe849fcb297c247865a161f995cc29de7aa823afdd75aaaddc1419b","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"b77e16112127a4b169ef0b8c3a4d730edf459c5f25fe52d5e436a6919206c4d7","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"fbffd9337146eff822c7c00acbb78b01ea7ea23987f6c961eba689349e744f8c","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"a995c0e49b721312f74fdfb89e4ba29bd9824c770bbb4021d74d2bf560e4c6bd","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"c7b3542146734342e440a84b213384bfa188835537ddbda50d30766f0593aff9","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"ce6180fa19b1cccd07ee7f7dbb9a367ac19c0ed160573e4686425060b6df7f57","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"3f02e2476bccb9dbe21280d6090f0df17d2f66b74711489415a8aa4df73c9675","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"45e3ab34c1c013c8ab2dc1ba4c80c780744b13b5676800ae2e3be27ae862c40c","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"805c86f6cca8d7702a62a844856dbaa2a3fd2abef0536e65d48732441dde5b5b","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"e42e397f1a5a77994f0185fd1466520691456c772d06bf843e5084ceb879a0ad","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"f4c2b41f90c95b1c532ecc874bd3c111865793b23aebcc1c3cbbabcd5d76ffb0","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"ab26191cfad5b66afa11b8bf935ef1cd88fabfcb28d30b2dfa6fad877d050332","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"2088bc26531e38fb05eedac2951480db5309f6be3fa4a08d2221abb0f5b4200d","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"cb9d366c425fea79716a8fb3af0d78e6b22ebbab3bd64d25063b42dc9f531c1e","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"500934a8089c26d57ebdb688fc9757389bb6207a3c8f0674d68efa900d2abb34","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"689da16f46e647cef0d64b0def88910e818a5877ca5379ede156ca3afb780ac3","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"bc21cc8b6fee4f4c2440d08035b7ea3c06b3511314c8bab6bef7a92de58a2593","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"7ca53d13d2957003abb47922a71866ba7cb2068f8d154877c596d63c359fed25","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"54725f8c4df3d900cb4dac84b64689ce29548da0b4e9b7c2de61d41c79293611","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"e5594bc3076ac29e6c1ebda77939bc4c8833de72f654b6e376862c0473199323","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"2f3eb332c2d73e729f3364fcc0c2b375e72a121e8157d25a82d67a138c83a95c","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"6f4427f9642ce8d500970e4e69d1397f64072ab73b97e476b4002a646ac743b1","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"48915f327cd1dea4d7bd358d9dc7732f58f9e1626a29cc0c05c8c692419d9bb7","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"b7bf9377723203b5a6a4b920164df22d56a43f593269ba6ae1fdc97774b68855","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"db9709688f82c9e5f65a119c64d835f906efe5f559d08b11642d56eb85b79357","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"4b25b8c874acd1a4cf8444c3617e037d444d19080ac9f634b405583fd10ce1f7","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"37be57d7c90cf1f8112ee2636a068d8fd181289f82b744160ec56a7dc158a9f5","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"a917a49ac94cd26b754ab84e113369a75d1a47a710661d7cd25e961cc797065f","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"6d3261badeb7843d157ef3e6f5d1427d0eeb0af0cf9df84a62cfd29fd47ac86e","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"195daca651dde22f2167ac0d0a05e215308119a3100f5e6268e8317d05a92526","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"8b11e4285cd2bb164a4dc09248bdec69e9842517db4ca47c1ba913011e44ff2f","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"0508571a52475e245b02bc50fa1394065a0a3d05277fbf5120c3784b85651799","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"8f9af488f510c3015af3cc8c267a9e9d96c4dd38a1fdff0e11dc5a544711415b","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"fc611fea8d30ea72c6bbfb599c9b4d393ce22e2f5bfef2172534781e7d138104","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"1ce14b81c5cc821994aa8ec1d42b220dd41b27fcc06373bce3958af7421b77d4","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"b3a048b3e9302ef9a34ef4ebb9aecfb28b66abb3bce577206a79fee559c230da","signature":false,"affectsGlobalScope":true,"impliedFormat":1},{"version":"01a30f9e8582b369075c0808df71121e6855cb06fd8d3d39511d9ebb66405205","signature":false,"impliedFormat":1},{"version":"2c9e8dd75abfe42ee48e22150762d74c940a46469bdf96e0c7fcbb319b4d77f2","signature":false}],"root":[64],"options":{"allowImportingTsExtensions":true,"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"exactOptionalPropertyTypes":true,"module":99,"noEmitOnError":false,"noFallthroughCasesInSwitch":true,"noImplicitOverride":true,"noImplicitReturns":true,"noUncheckedIndexedAccess":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./types","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":9,"useDefineForClassFields":true,"verbatimModuleSyntax":true},"changeFileSet":[61,62,12,10,11,16,15,2,17,18,19,20,21,22,23,24,3,25,26,4,27,31,28,29,30,32,33,34,5,35,36,37,38,6,42,39,40,41,43,7,44,49,50,45,46,47,48,8,54,51,52,53,55,9,56,63,57,58,60,59,1,14,13,64],"version":"6.0.2"}
|