ai-tests 2.1.1 → 2.1.3
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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +6 -2
- package/CHANGELOG.md +2 -0
- package/LICENSE +21 -0
- package/dist/assertions.d.ts +79 -7
- package/dist/assertions.d.ts.map +1 -1
- package/dist/assertions.js +80 -14
- package/dist/assertions.js.map +1 -1
- package/package.json +12 -12
- package/src/assertions.ts +143 -32
- package/test/type-safety-assertions.test.ts +201 -0
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> ai-tests@2.
|
|
3
|
-
> vitest
|
|
2
|
+
> ai-tests@2.1.1 test /Users/nathanclevenger/projects/primitives.org.ai/packages/ai-tests
|
|
3
|
+
> vitest
|
|
4
4
|
|
|
5
|
+
|
|
6
|
+
DEV v2.1.9 /Users/nathanclevenger/projects/primitives.org.ai/packages/ai-tests
|
|
7
|
+
|
|
8
|
+
[vpw:info] Starting isolated runtimes for vitest.config.ts...
|
package/CHANGELOG.md
CHANGED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 .org.ai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/assertions.d.ts
CHANGED
|
@@ -5,11 +5,29 @@
|
|
|
5
5
|
* Uses Chai under the hood for battle-tested assertions.
|
|
6
6
|
*/
|
|
7
7
|
import { RpcTarget } from 'cloudflare:workers';
|
|
8
|
+
/**
|
|
9
|
+
* Type for constructor functions that can be used with instanceof assertions.
|
|
10
|
+
* Matches any class or function that can construct instances.
|
|
11
|
+
*/
|
|
12
|
+
type Constructor<T = unknown> = new (...args: any[]) => T;
|
|
13
|
+
/**
|
|
14
|
+
* Type for error-like values that can be used with throw assertions.
|
|
15
|
+
* Chai's throw() accepts:
|
|
16
|
+
* - Error constructor (e.g., TypeError, RangeError)
|
|
17
|
+
* - Error instance (e.g., new Error('message'))
|
|
18
|
+
* - String for message matching
|
|
19
|
+
* - RegExp for pattern matching
|
|
20
|
+
*/
|
|
21
|
+
type ThrowableMatch = string | RegExp | Error | Constructor<Error>;
|
|
8
22
|
/**
|
|
9
23
|
* Wrapper around Chai's expect that extends RpcTarget
|
|
10
24
|
* This allows the assertion chain to work over RPC with promise pipelining
|
|
11
25
|
*/
|
|
12
26
|
export declare class Assertion extends RpcTarget {
|
|
27
|
+
/**
|
|
28
|
+
* Internal Chai assertion chain.
|
|
29
|
+
* @see ChaiAssertionChain for explanation of the type choice.
|
|
30
|
+
*/
|
|
13
31
|
private assertion;
|
|
14
32
|
constructor(value: unknown, message?: string);
|
|
15
33
|
get to(): this;
|
|
@@ -29,13 +47,49 @@ export declare class Assertion extends RpcTarget {
|
|
|
29
47
|
get does(): this;
|
|
30
48
|
get still(): this;
|
|
31
49
|
get also(): this;
|
|
50
|
+
/**
|
|
51
|
+
* Negation flag - inverts the assertion.
|
|
52
|
+
* @remarks Type cast needed: Chai's .not returns Chai.Assertion, which matches our type.
|
|
53
|
+
*/
|
|
32
54
|
get not(): Assertion;
|
|
55
|
+
/**
|
|
56
|
+
* Deep flag - enables deep equality comparisons.
|
|
57
|
+
* @remarks Type cast needed: Chai's .deep returns Chai.Deep, but at runtime
|
|
58
|
+
* it has all the methods we need. We cast to maintain our wrapper's type.
|
|
59
|
+
*/
|
|
33
60
|
get deep(): Assertion;
|
|
61
|
+
/**
|
|
62
|
+
* Nested flag - enables nested property access with dot notation.
|
|
63
|
+
* @remarks Type cast needed: Chai's .nested returns Chai.Nested, cast to our chain type.
|
|
64
|
+
*/
|
|
34
65
|
get nested(): Assertion;
|
|
66
|
+
/**
|
|
67
|
+
* Own flag - only checks own properties, not inherited.
|
|
68
|
+
* @remarks Type cast needed: Chai's .own returns Chai.Own, cast to our chain type.
|
|
69
|
+
*/
|
|
35
70
|
get own(): Assertion;
|
|
71
|
+
/**
|
|
72
|
+
* Ordered flag - requires members to be in order.
|
|
73
|
+
* @remarks Type cast needed: Chai's .ordered returns Chai.Ordered, cast to our chain type.
|
|
74
|
+
*/
|
|
36
75
|
get ordered(): Assertion;
|
|
76
|
+
/**
|
|
77
|
+
* Any flag - requires at least one key match.
|
|
78
|
+
* @remarks Type cast needed: Chai's .any returns Chai.KeyFilter, cast to our chain type.
|
|
79
|
+
*/
|
|
37
80
|
get any(): Assertion;
|
|
81
|
+
/**
|
|
82
|
+
* All flag - requires all keys to match.
|
|
83
|
+
* @remarks Type cast needed: Chai's .all returns Chai.KeyFilter, cast to our chain type.
|
|
84
|
+
*/
|
|
38
85
|
get all(): Assertion;
|
|
86
|
+
/**
|
|
87
|
+
* Length chain - for asserting on length property.
|
|
88
|
+
* @remarks Type cast needed: Chai's .length returns Chai.Length which is quite different
|
|
89
|
+
* from Chai.Assertion (it's also callable). We cast through unknown because Length
|
|
90
|
+
* doesn't directly overlap with Assertion in TypeScript's structural type system,
|
|
91
|
+
* but at runtime the object has all methods we need.
|
|
92
|
+
*/
|
|
39
93
|
get length(): Assertion;
|
|
40
94
|
get ok(): this;
|
|
41
95
|
get true(): this;
|
|
@@ -64,8 +118,8 @@ export declare class Assertion extends RpcTarget {
|
|
|
64
118
|
lte(value: number, message?: string): this;
|
|
65
119
|
lessThanOrEqual(value: number, message?: string): this;
|
|
66
120
|
within(start: number, finish: number, message?: string): this;
|
|
67
|
-
instanceof(constructor:
|
|
68
|
-
instanceOf(constructor:
|
|
121
|
+
instanceof(constructor: Constructor, message?: string): this;
|
|
122
|
+
instanceOf(constructor: Constructor, message?: string): this;
|
|
69
123
|
property(name: string, value?: unknown, message?: string): this;
|
|
70
124
|
ownProperty(name: string, message?: string): this;
|
|
71
125
|
haveOwnProperty(name: string, message?: string): this;
|
|
@@ -76,9 +130,22 @@ export declare class Assertion extends RpcTarget {
|
|
|
76
130
|
string(str: string, message?: string): this;
|
|
77
131
|
keys(...keys: string[]): this;
|
|
78
132
|
key(...keys: string[]): this;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Asserts that the function throws an error.
|
|
135
|
+
*
|
|
136
|
+
* @param errorLike - Error constructor, instance, string, or RegExp to match
|
|
137
|
+
* @param errMsgMatcher - String or RegExp to match error message (when errorLike is constructor/instance)
|
|
138
|
+
* @param message - Custom assertion message
|
|
139
|
+
*
|
|
140
|
+
* @remarks
|
|
141
|
+
* Chai's throw() has two overloads that TypeScript can't resolve with our union type.
|
|
142
|
+
* We use runtime type checking to call the appropriate overload, then use a type
|
|
143
|
+
* assertion to satisfy TypeScript. This is safe because Chai accepts all these
|
|
144
|
+
* combinations at runtime.
|
|
145
|
+
*/
|
|
146
|
+
throw(errorLike?: ThrowableMatch, errMsgMatcher?: string | RegExp, message?: string): this;
|
|
147
|
+
throws(errorLike?: ThrowableMatch, errMsgMatcher?: string | RegExp, message?: string): this;
|
|
148
|
+
Throw(errorLike?: ThrowableMatch, errMsgMatcher?: string | RegExp, message?: string): this;
|
|
82
149
|
respondTo(method: string, message?: string): this;
|
|
83
150
|
respondsTo(method: string, message?: string): this;
|
|
84
151
|
satisfy(matcher: (val: unknown) => boolean, message?: string): this;
|
|
@@ -107,13 +174,17 @@ export declare class Assertion extends RpcTarget {
|
|
|
107
174
|
toHaveProperty(path: string, value?: unknown): this;
|
|
108
175
|
toMatch(pattern: RegExp | string): this;
|
|
109
176
|
toMatchObject(obj: object): this;
|
|
110
|
-
|
|
177
|
+
/**
|
|
178
|
+
* Vitest-compatible: Asserts that the function throws.
|
|
179
|
+
* @remarks Uses same runtime type checking as throw() to handle Chai's overloads.
|
|
180
|
+
*/
|
|
181
|
+
toThrow(expected?: ThrowableMatch): this;
|
|
111
182
|
toBeGreaterThan(n: number): this;
|
|
112
183
|
toBeLessThan(n: number): this;
|
|
113
184
|
toBeGreaterThanOrEqual(n: number): this;
|
|
114
185
|
toBeLessThanOrEqual(n: number): this;
|
|
115
186
|
toBeCloseTo(n: number, digits?: number): this;
|
|
116
|
-
toBeInstanceOf(cls:
|
|
187
|
+
toBeInstanceOf(cls: Constructor): this;
|
|
117
188
|
toBeTypeOf(type: string): this;
|
|
118
189
|
}
|
|
119
190
|
/**
|
|
@@ -129,4 +200,5 @@ export declare function expect(value: unknown, message?: string): Assertion;
|
|
|
129
200
|
* Since we can't modify Object.prototype over RPC, this takes a value
|
|
130
201
|
*/
|
|
131
202
|
export declare function should(value: unknown): Assertion;
|
|
203
|
+
export {};
|
|
132
204
|
//# sourceMappingURL=assertions.d.ts.map
|
package/dist/assertions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../src/assertions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAK9C;;;GAGG;AACH,qBAAa,SAAU,SAAQ,SAAS;
|
|
1
|
+
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../src/assertions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAK9C;;;GAGG;AAEH,KAAK,WAAW,CAAC,CAAC,GAAG,OAAO,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;AAEzD;;;;;;;GAOG;AACH,KAAK,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,CAAA;AAkClE;;;GAGG;AACH,qBAAa,SAAU,SAAQ,SAAS;IACtC;;;OAGG;IACH,OAAO,CAAC,SAAS,CAAoB;gBAEzB,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM;IAM5C,IAAI,EAAE,SAAkB;IACxB,IAAI,EAAE,SAAkB;IACxB,IAAI,IAAI,SAAkB;IAC1B,IAAI,EAAE,SAAkB;IACxB,IAAI,IAAI,SAAkB;IAC1B,IAAI,KAAK,SAAkB;IAC3B,IAAI,GAAG,SAAkB;IACzB,IAAI,GAAG,SAAkB;IACzB,IAAI,IAAI,SAAkB;IAC1B,IAAI,IAAI,SAAkB;IAC1B,IAAI,EAAE,SAAkB;IACxB,IAAI,EAAE,SAAkB;IACxB,IAAI,IAAI,SAAkB;IAC1B,IAAI,GAAG,SAAkB;IACzB,IAAI,IAAI,SAAkB;IAC1B,IAAI,KAAK,SAAkB;IAC3B,IAAI,IAAI,SAAkB;IAE1B;;;OAGG;IACH,IAAI,GAAG,IAAI,SAAS,CAGnB;IAED;;;;OAIG;IACH,IAAI,IAAI,IAAI,SAAS,CAGpB;IAED;;;OAGG;I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AG,SAAS,CAElE;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAEhD"}
|
package/dist/assertions.js
CHANGED
|
@@ -13,8 +13,10 @@ chai.should();
|
|
|
13
13
|
* This allows the assertion chain to work over RPC with promise pipelining
|
|
14
14
|
*/
|
|
15
15
|
export class Assertion extends RpcTarget {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Internal Chai assertion chain.
|
|
18
|
+
* @see ChaiAssertionChain for explanation of the type choice.
|
|
19
|
+
*/
|
|
18
20
|
assertion;
|
|
19
21
|
constructor(value, message) {
|
|
20
22
|
super();
|
|
@@ -38,42 +40,70 @@ export class Assertion extends RpcTarget {
|
|
|
38
40
|
get does() { return this; }
|
|
39
41
|
get still() { return this; }
|
|
40
42
|
get also() { return this; }
|
|
41
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Negation flag - inverts the assertion.
|
|
45
|
+
* @remarks Type cast needed: Chai's .not returns Chai.Assertion, which matches our type.
|
|
46
|
+
*/
|
|
42
47
|
get not() {
|
|
43
48
|
this.assertion = this.assertion.not;
|
|
44
49
|
return this;
|
|
45
50
|
}
|
|
46
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Deep flag - enables deep equality comparisons.
|
|
53
|
+
* @remarks Type cast needed: Chai's .deep returns Chai.Deep, but at runtime
|
|
54
|
+
* it has all the methods we need. We cast to maintain our wrapper's type.
|
|
55
|
+
*/
|
|
47
56
|
get deep() {
|
|
48
57
|
this.assertion = this.assertion.deep;
|
|
49
58
|
return this;
|
|
50
59
|
}
|
|
51
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Nested flag - enables nested property access with dot notation.
|
|
62
|
+
* @remarks Type cast needed: Chai's .nested returns Chai.Nested, cast to our chain type.
|
|
63
|
+
*/
|
|
52
64
|
get nested() {
|
|
53
65
|
this.assertion = this.assertion.nested;
|
|
54
66
|
return this;
|
|
55
67
|
}
|
|
56
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Own flag - only checks own properties, not inherited.
|
|
70
|
+
* @remarks Type cast needed: Chai's .own returns Chai.Own, cast to our chain type.
|
|
71
|
+
*/
|
|
57
72
|
get own() {
|
|
58
73
|
this.assertion = this.assertion.own;
|
|
59
74
|
return this;
|
|
60
75
|
}
|
|
61
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Ordered flag - requires members to be in order.
|
|
78
|
+
* @remarks Type cast needed: Chai's .ordered returns Chai.Ordered, cast to our chain type.
|
|
79
|
+
*/
|
|
62
80
|
get ordered() {
|
|
63
81
|
this.assertion = this.assertion.ordered;
|
|
64
82
|
return this;
|
|
65
83
|
}
|
|
66
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Any flag - requires at least one key match.
|
|
86
|
+
* @remarks Type cast needed: Chai's .any returns Chai.KeyFilter, cast to our chain type.
|
|
87
|
+
*/
|
|
67
88
|
get any() {
|
|
68
89
|
this.assertion = this.assertion.any;
|
|
69
90
|
return this;
|
|
70
91
|
}
|
|
71
|
-
|
|
92
|
+
/**
|
|
93
|
+
* All flag - requires all keys to match.
|
|
94
|
+
* @remarks Type cast needed: Chai's .all returns Chai.KeyFilter, cast to our chain type.
|
|
95
|
+
*/
|
|
72
96
|
get all() {
|
|
73
97
|
this.assertion = this.assertion.all;
|
|
74
98
|
return this;
|
|
75
99
|
}
|
|
76
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Length chain - for asserting on length property.
|
|
102
|
+
* @remarks Type cast needed: Chai's .length returns Chai.Length which is quite different
|
|
103
|
+
* from Chai.Assertion (it's also callable). We cast through unknown because Length
|
|
104
|
+
* doesn't directly overlap with Assertion in TypeScript's structural type system,
|
|
105
|
+
* but at runtime the object has all methods we need.
|
|
106
|
+
*/
|
|
77
107
|
get length() {
|
|
78
108
|
this.assertion = this.assertion.length;
|
|
79
109
|
return this;
|
|
@@ -174,7 +204,12 @@ export class Assertion extends RpcTarget {
|
|
|
174
204
|
return this.ownProperty(name, message);
|
|
175
205
|
}
|
|
176
206
|
ownPropertyDescriptor(name, descriptor, message) {
|
|
177
|
-
|
|
207
|
+
if (descriptor !== undefined) {
|
|
208
|
+
this.assertion.ownPropertyDescriptor(name, descriptor, message);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
this.assertion.ownPropertyDescriptor(name, message);
|
|
212
|
+
}
|
|
178
213
|
return this;
|
|
179
214
|
}
|
|
180
215
|
lengthOf(n, message) {
|
|
@@ -199,8 +234,31 @@ export class Assertion extends RpcTarget {
|
|
|
199
234
|
key(...keys) {
|
|
200
235
|
return this.keys(...keys);
|
|
201
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Asserts that the function throws an error.
|
|
239
|
+
*
|
|
240
|
+
* @param errorLike - Error constructor, instance, string, or RegExp to match
|
|
241
|
+
* @param errMsgMatcher - String or RegExp to match error message (when errorLike is constructor/instance)
|
|
242
|
+
* @param message - Custom assertion message
|
|
243
|
+
*
|
|
244
|
+
* @remarks
|
|
245
|
+
* Chai's throw() has two overloads that TypeScript can't resolve with our union type.
|
|
246
|
+
* We use runtime type checking to call the appropriate overload, then use a type
|
|
247
|
+
* assertion to satisfy TypeScript. This is safe because Chai accepts all these
|
|
248
|
+
* combinations at runtime.
|
|
249
|
+
*/
|
|
202
250
|
throw(errorLike, errMsgMatcher, message) {
|
|
203
|
-
|
|
251
|
+
if (errorLike === undefined) {
|
|
252
|
+
this.assertion.throw();
|
|
253
|
+
}
|
|
254
|
+
else if (typeof errorLike === 'string' || errorLike instanceof RegExp) {
|
|
255
|
+
// First overload: (expected?: string | RegExp, message?: string)
|
|
256
|
+
this.assertion.throw(errorLike, errMsgMatcher);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
// Second overload: (constructor: Error | Function, expected?: string | RegExp, message?: string)
|
|
260
|
+
this.assertion.throw(errorLike, errMsgMatcher, message);
|
|
261
|
+
}
|
|
204
262
|
return this;
|
|
205
263
|
}
|
|
206
264
|
throws(errorLike, errMsgMatcher, message) {
|
|
@@ -325,12 +383,20 @@ export class Assertion extends RpcTarget {
|
|
|
325
383
|
this.assertion.deep.include(obj);
|
|
326
384
|
return this;
|
|
327
385
|
}
|
|
386
|
+
/**
|
|
387
|
+
* Vitest-compatible: Asserts that the function throws.
|
|
388
|
+
* @remarks Uses same runtime type checking as throw() to handle Chai's overloads.
|
|
389
|
+
*/
|
|
328
390
|
toThrow(expected) {
|
|
329
|
-
if (expected) {
|
|
391
|
+
if (expected === undefined) {
|
|
392
|
+
this.assertion.throw();
|
|
393
|
+
}
|
|
394
|
+
else if (typeof expected === 'string' || expected instanceof RegExp) {
|
|
330
395
|
this.assertion.throw(expected);
|
|
331
396
|
}
|
|
332
397
|
else {
|
|
333
|
-
|
|
398
|
+
// Error instance or constructor
|
|
399
|
+
this.assertion.throw(expected);
|
|
334
400
|
}
|
|
335
401
|
return this;
|
|
336
402
|
}
|
package/dist/assertions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.js","sourceRoot":"","sources":["../src/assertions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C,2BAA2B;AAC3B,IAAI,CAAC,MAAM,EAAE,CAAA;AAEb;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC,2EAA2E;IAC3E,2DAA2D;IACnD,SAAS,CAAK;IAEtB,YAAY,KAAc,EAAE,OAAgB;QAC1C,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAC9C,CAAC;IAED,4BAA4B;IAC5B,IAAI,EAAE,KAAK,OAAO,IAAI,CAAA,CAAC,CAAC;IACxB,IAAI,EAAE,KAAK,OAAO,IAAI,CAAA,CAAC,CAAC;IACxB,IAAI,IAAI,KAA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,CAAC;IAED,cAAc,CAAC,GAAgB;QAC7B,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;QAC9B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QACtB,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;AAEjC;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,KAAc,EAAE,OAAgB;IACrD,OAAO,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;AACtC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,CAAA;AAC7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-tests",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Test utilities worker - expect, should, assert, describe, it via RPC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,15 +22,6 @@
|
|
|
22
22
|
"types": "./dist/local.d.ts"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "tsc -p tsconfig.json",
|
|
27
|
-
"dev": "tsc -p tsconfig.json --watch",
|
|
28
|
-
"test": "vitest",
|
|
29
|
-
"typecheck": "tsc --noEmit",
|
|
30
|
-
"lint": "eslint .",
|
|
31
|
-
"clean": "rm -rf dist",
|
|
32
|
-
"deploy": "wrangler deploy"
|
|
33
|
-
},
|
|
34
25
|
"dependencies": {
|
|
35
26
|
"chai": "^5.1.0"
|
|
36
27
|
},
|
|
@@ -53,5 +44,14 @@
|
|
|
53
44
|
"rpc",
|
|
54
45
|
"primitives"
|
|
55
46
|
],
|
|
56
|
-
"license": "MIT"
|
|
57
|
-
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsc -p tsconfig.json",
|
|
50
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
51
|
+
"test": "vitest",
|
|
52
|
+
"typecheck": "tsc --noEmit",
|
|
53
|
+
"lint": "eslint .",
|
|
54
|
+
"clean": "rm -rf dist",
|
|
55
|
+
"deploy": "wrangler deploy"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/assertions.ts
CHANGED
|
@@ -11,14 +11,65 @@ import { RpcTarget } from 'cloudflare:workers'
|
|
|
11
11
|
// Initialize chai's should
|
|
12
12
|
chai.should()
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Type for constructor functions that can be used with instanceof assertions.
|
|
16
|
+
* Matches any class or function that can construct instances.
|
|
17
|
+
*/
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
type Constructor<T = unknown> = new (...args: any[]) => T
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Type for error-like values that can be used with throw assertions.
|
|
23
|
+
* Chai's throw() accepts:
|
|
24
|
+
* - Error constructor (e.g., TypeError, RangeError)
|
|
25
|
+
* - Error instance (e.g., new Error('message'))
|
|
26
|
+
* - String for message matching
|
|
27
|
+
* - RegExp for pattern matching
|
|
28
|
+
*/
|
|
29
|
+
type ThrowableMatch = string | RegExp | Error | Constructor<Error>
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Internal type for Chai assertion chain.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* **Why we use Chai.Assertion here:**
|
|
36
|
+
*
|
|
37
|
+
* Chai's fluent API uses a chainable pattern where each flag (.not, .deep, .nested, etc.)
|
|
38
|
+
* returns a different TypeScript interface:
|
|
39
|
+
* - Chai.Assertion: Base type from expect()
|
|
40
|
+
* - Chai.Deep: Returned after .deep (has subset of properties)
|
|
41
|
+
* - Chai.Nested, Chai.Own, etc.: Other flag-specific types
|
|
42
|
+
*
|
|
43
|
+
* These types form a complex hierarchy where not all methods exist on all types.
|
|
44
|
+
* For example, Chai.Deep has .equal() but not .ok, while Chai.KeyFilter has
|
|
45
|
+
* .keys() but not .equal().
|
|
46
|
+
*
|
|
47
|
+
* Our wrapper class stores the current assertion state and calls methods on it.
|
|
48
|
+
* At runtime, all these methods exist because Chai's actual implementation always
|
|
49
|
+
* has them - the type restrictions are for API guidance, not runtime behavior.
|
|
50
|
+
*
|
|
51
|
+
* We use Chai.Assertion (the most complete type) because:
|
|
52
|
+
* 1. It has all the methods we need to call
|
|
53
|
+
* 2. The assignment from flag types to Chai.Assertion is unsound in strict TS,
|
|
54
|
+
* but at runtime these objects have all the methods we need
|
|
55
|
+
* 3. We wrap the result in our own Assertion class, so the internal type
|
|
56
|
+
* doesn't leak to consumers
|
|
57
|
+
*
|
|
58
|
+
* The type assertions in the flag getters (.deep, .nested, etc.) are intentional
|
|
59
|
+
* and documented. They bridge Chai's complex type hierarchy to our simpler wrapper.
|
|
60
|
+
*/
|
|
61
|
+
type ChaiAssertionChain = Chai.Assertion
|
|
62
|
+
|
|
14
63
|
/**
|
|
15
64
|
* Wrapper around Chai's expect that extends RpcTarget
|
|
16
65
|
* This allows the assertion chain to work over RPC with promise pipelining
|
|
17
66
|
*/
|
|
18
67
|
export class Assertion extends RpcTarget {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Internal Chai assertion chain.
|
|
70
|
+
* @see ChaiAssertionChain for explanation of the type choice.
|
|
71
|
+
*/
|
|
72
|
+
private assertion: ChaiAssertionChain
|
|
22
73
|
|
|
23
74
|
constructor(value: unknown, message?: string) {
|
|
24
75
|
super()
|
|
@@ -44,51 +95,79 @@ export class Assertion extends RpcTarget {
|
|
|
44
95
|
get still() { return this }
|
|
45
96
|
get also() { return this }
|
|
46
97
|
|
|
47
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Negation flag - inverts the assertion.
|
|
100
|
+
* @remarks Type cast needed: Chai's .not returns Chai.Assertion, which matches our type.
|
|
101
|
+
*/
|
|
48
102
|
get not(): Assertion {
|
|
49
103
|
this.assertion = this.assertion.not
|
|
50
104
|
return this
|
|
51
105
|
}
|
|
52
106
|
|
|
53
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Deep flag - enables deep equality comparisons.
|
|
109
|
+
* @remarks Type cast needed: Chai's .deep returns Chai.Deep, but at runtime
|
|
110
|
+
* it has all the methods we need. We cast to maintain our wrapper's type.
|
|
111
|
+
*/
|
|
54
112
|
get deep(): Assertion {
|
|
55
|
-
this.assertion = this.assertion.deep
|
|
113
|
+
this.assertion = this.assertion.deep as ChaiAssertionChain
|
|
56
114
|
return this
|
|
57
115
|
}
|
|
58
116
|
|
|
59
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Nested flag - enables nested property access with dot notation.
|
|
119
|
+
* @remarks Type cast needed: Chai's .nested returns Chai.Nested, cast to our chain type.
|
|
120
|
+
*/
|
|
60
121
|
get nested(): Assertion {
|
|
61
|
-
this.assertion = this.assertion.nested
|
|
122
|
+
this.assertion = this.assertion.nested as ChaiAssertionChain
|
|
62
123
|
return this
|
|
63
124
|
}
|
|
64
125
|
|
|
65
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Own flag - only checks own properties, not inherited.
|
|
128
|
+
* @remarks Type cast needed: Chai's .own returns Chai.Own, cast to our chain type.
|
|
129
|
+
*/
|
|
66
130
|
get own(): Assertion {
|
|
67
|
-
this.assertion = this.assertion.own
|
|
131
|
+
this.assertion = this.assertion.own as ChaiAssertionChain
|
|
68
132
|
return this
|
|
69
133
|
}
|
|
70
134
|
|
|
71
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Ordered flag - requires members to be in order.
|
|
137
|
+
* @remarks Type cast needed: Chai's .ordered returns Chai.Ordered, cast to our chain type.
|
|
138
|
+
*/
|
|
72
139
|
get ordered(): Assertion {
|
|
73
|
-
this.assertion = this.assertion.ordered
|
|
140
|
+
this.assertion = this.assertion.ordered as ChaiAssertionChain
|
|
74
141
|
return this
|
|
75
142
|
}
|
|
76
143
|
|
|
77
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Any flag - requires at least one key match.
|
|
146
|
+
* @remarks Type cast needed: Chai's .any returns Chai.KeyFilter, cast to our chain type.
|
|
147
|
+
*/
|
|
78
148
|
get any(): Assertion {
|
|
79
|
-
this.assertion = this.assertion.any
|
|
149
|
+
this.assertion = this.assertion.any as ChaiAssertionChain
|
|
80
150
|
return this
|
|
81
151
|
}
|
|
82
152
|
|
|
83
|
-
|
|
153
|
+
/**
|
|
154
|
+
* All flag - requires all keys to match.
|
|
155
|
+
* @remarks Type cast needed: Chai's .all returns Chai.KeyFilter, cast to our chain type.
|
|
156
|
+
*/
|
|
84
157
|
get all(): Assertion {
|
|
85
|
-
this.assertion = this.assertion.all
|
|
158
|
+
this.assertion = this.assertion.all as ChaiAssertionChain
|
|
86
159
|
return this
|
|
87
160
|
}
|
|
88
161
|
|
|
89
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Length chain - for asserting on length property.
|
|
164
|
+
* @remarks Type cast needed: Chai's .length returns Chai.Length which is quite different
|
|
165
|
+
* from Chai.Assertion (it's also callable). We cast through unknown because Length
|
|
166
|
+
* doesn't directly overlap with Assertion in TypeScript's structural type system,
|
|
167
|
+
* but at runtime the object has all methods we need.
|
|
168
|
+
*/
|
|
90
169
|
get length(): Assertion {
|
|
91
|
-
this.assertion = this.assertion.length
|
|
170
|
+
this.assertion = this.assertion.length as unknown as ChaiAssertionChain
|
|
92
171
|
return this
|
|
93
172
|
}
|
|
94
173
|
|
|
@@ -183,12 +262,12 @@ export class Assertion extends RpcTarget {
|
|
|
183
262
|
return this
|
|
184
263
|
}
|
|
185
264
|
|
|
186
|
-
instanceof(constructor:
|
|
187
|
-
this.assertion.instanceof(constructor
|
|
265
|
+
instanceof(constructor: Constructor, message?: string) {
|
|
266
|
+
this.assertion.instanceof(constructor, message)
|
|
188
267
|
return this
|
|
189
268
|
}
|
|
190
269
|
|
|
191
|
-
instanceOf(constructor:
|
|
270
|
+
instanceOf(constructor: Constructor, message?: string) {
|
|
192
271
|
return this.instanceof(constructor, message)
|
|
193
272
|
}
|
|
194
273
|
|
|
@@ -211,7 +290,11 @@ export class Assertion extends RpcTarget {
|
|
|
211
290
|
}
|
|
212
291
|
|
|
213
292
|
ownPropertyDescriptor(name: string, descriptor?: PropertyDescriptor, message?: string) {
|
|
214
|
-
|
|
293
|
+
if (descriptor !== undefined) {
|
|
294
|
+
this.assertion.ownPropertyDescriptor(name, descriptor, message)
|
|
295
|
+
} else {
|
|
296
|
+
this.assertion.ownPropertyDescriptor(name, message)
|
|
297
|
+
}
|
|
215
298
|
return this
|
|
216
299
|
}
|
|
217
300
|
|
|
@@ -243,16 +326,37 @@ export class Assertion extends RpcTarget {
|
|
|
243
326
|
return this.keys(...keys)
|
|
244
327
|
}
|
|
245
328
|
|
|
246
|
-
|
|
247
|
-
|
|
329
|
+
/**
|
|
330
|
+
* Asserts that the function throws an error.
|
|
331
|
+
*
|
|
332
|
+
* @param errorLike - Error constructor, instance, string, or RegExp to match
|
|
333
|
+
* @param errMsgMatcher - String or RegExp to match error message (when errorLike is constructor/instance)
|
|
334
|
+
* @param message - Custom assertion message
|
|
335
|
+
*
|
|
336
|
+
* @remarks
|
|
337
|
+
* Chai's throw() has two overloads that TypeScript can't resolve with our union type.
|
|
338
|
+
* We use runtime type checking to call the appropriate overload, then use a type
|
|
339
|
+
* assertion to satisfy TypeScript. This is safe because Chai accepts all these
|
|
340
|
+
* combinations at runtime.
|
|
341
|
+
*/
|
|
342
|
+
throw(errorLike?: ThrowableMatch, errMsgMatcher?: string | RegExp, message?: string) {
|
|
343
|
+
if (errorLike === undefined) {
|
|
344
|
+
this.assertion.throw()
|
|
345
|
+
} else if (typeof errorLike === 'string' || errorLike instanceof RegExp) {
|
|
346
|
+
// First overload: (expected?: string | RegExp, message?: string)
|
|
347
|
+
this.assertion.throw(errorLike, errMsgMatcher as string | undefined)
|
|
348
|
+
} else {
|
|
349
|
+
// Second overload: (constructor: Error | Function, expected?: string | RegExp, message?: string)
|
|
350
|
+
this.assertion.throw(errorLike as Error | Function, errMsgMatcher, message)
|
|
351
|
+
}
|
|
248
352
|
return this
|
|
249
353
|
}
|
|
250
354
|
|
|
251
|
-
throws(errorLike?:
|
|
355
|
+
throws(errorLike?: ThrowableMatch, errMsgMatcher?: string | RegExp, message?: string) {
|
|
252
356
|
return this.throw(errorLike, errMsgMatcher, message)
|
|
253
357
|
}
|
|
254
358
|
|
|
255
|
-
Throw(errorLike?:
|
|
359
|
+
Throw(errorLike?: ThrowableMatch, errMsgMatcher?: string | RegExp, message?: string) {
|
|
256
360
|
return this.throw(errorLike, errMsgMatcher, message)
|
|
257
361
|
}
|
|
258
362
|
|
|
@@ -398,11 +502,18 @@ export class Assertion extends RpcTarget {
|
|
|
398
502
|
return this
|
|
399
503
|
}
|
|
400
504
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
505
|
+
/**
|
|
506
|
+
* Vitest-compatible: Asserts that the function throws.
|
|
507
|
+
* @remarks Uses same runtime type checking as throw() to handle Chai's overloads.
|
|
508
|
+
*/
|
|
509
|
+
toThrow(expected?: ThrowableMatch) {
|
|
510
|
+
if (expected === undefined) {
|
|
405
511
|
this.assertion.throw()
|
|
512
|
+
} else if (typeof expected === 'string' || expected instanceof RegExp) {
|
|
513
|
+
this.assertion.throw(expected)
|
|
514
|
+
} else {
|
|
515
|
+
// Error instance or constructor
|
|
516
|
+
this.assertion.throw(expected as Error | Function)
|
|
406
517
|
}
|
|
407
518
|
return this
|
|
408
519
|
}
|
|
@@ -433,8 +544,8 @@ export class Assertion extends RpcTarget {
|
|
|
433
544
|
return this
|
|
434
545
|
}
|
|
435
546
|
|
|
436
|
-
toBeInstanceOf(cls:
|
|
437
|
-
this.assertion.instanceof(cls
|
|
547
|
+
toBeInstanceOf(cls: Constructor) {
|
|
548
|
+
this.assertion.instanceof(cls)
|
|
438
549
|
return this
|
|
439
550
|
}
|
|
440
551
|
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type safety tests for assertions.ts
|
|
3
|
+
*
|
|
4
|
+
* These tests verify proper TypeScript type inference and type safety
|
|
5
|
+
* for the assertion functions, particularly around the areas that
|
|
6
|
+
* previously used `as any` casts.
|
|
7
|
+
*/
|
|
8
|
+
import { describe, it, expectTypeOf, expect as vitestExpect } from 'vitest'
|
|
9
|
+
import { expect, Assertion } from '../src/assertions.js'
|
|
10
|
+
|
|
11
|
+
describe('Type Safety: Assertion', () => {
|
|
12
|
+
describe('instanceof type handling', () => {
|
|
13
|
+
it('accepts constructor functions', () => {
|
|
14
|
+
// Should accept class constructors
|
|
15
|
+
class MyClass {}
|
|
16
|
+
const assertion = expect(new MyClass()).instanceof(MyClass)
|
|
17
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('accepts built-in constructors', () => {
|
|
21
|
+
// Should accept Error constructor
|
|
22
|
+
const assertion = expect(new Error()).instanceof(Error)
|
|
23
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('accepts ErrorConstructor types', () => {
|
|
27
|
+
// Should work with various error types
|
|
28
|
+
const assertion1 = expect(new TypeError()).instanceof(TypeError)
|
|
29
|
+
const assertion2 = expect(new RangeError()).instanceof(RangeError)
|
|
30
|
+
expectTypeOf(assertion1).toEqualTypeOf<Assertion>()
|
|
31
|
+
expectTypeOf(assertion2).toEqualTypeOf<Assertion>()
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
describe('instanceOf type handling (alias)', () => {
|
|
36
|
+
it('accepts constructor functions', () => {
|
|
37
|
+
class MyClass {}
|
|
38
|
+
const assertion = expect(new MyClass()).instanceOf(MyClass)
|
|
39
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
describe('toBeInstanceOf type handling', () => {
|
|
44
|
+
it('accepts constructor functions', () => {
|
|
45
|
+
class MyClass {}
|
|
46
|
+
const assertion = expect(new MyClass()).toBeInstanceOf(MyClass)
|
|
47
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('accepts built-in constructors', () => {
|
|
51
|
+
const assertion = expect(new Error()).toBeInstanceOf(Error)
|
|
52
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
describe('throw type handling', () => {
|
|
57
|
+
it('accepts no arguments', () => {
|
|
58
|
+
const assertion = expect(() => { throw new Error() }).throw()
|
|
59
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('accepts string error message', () => {
|
|
63
|
+
const assertion = expect(() => { throw new Error('test') }).throw('test')
|
|
64
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('accepts RegExp pattern', () => {
|
|
68
|
+
const assertion = expect(() => { throw new Error('test') }).throw(/test/)
|
|
69
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('accepts Error instance', () => {
|
|
73
|
+
const err = new Error('test')
|
|
74
|
+
const assertion = expect(() => { throw err }).throw(err)
|
|
75
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('accepts Error constructor', () => {
|
|
79
|
+
const assertion = expect(() => { throw new TypeError() }).throw(TypeError)
|
|
80
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('accepts Error constructor with message pattern', () => {
|
|
84
|
+
const assertion = expect(() => { throw new Error('test') }).throw(Error, /test/)
|
|
85
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
describe('throws type handling (alias)', () => {
|
|
90
|
+
it('accepts Error constructor', () => {
|
|
91
|
+
const assertion = expect(() => { throw new TypeError() }).throws(TypeError)
|
|
92
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
describe('Throw type handling (alias)', () => {
|
|
97
|
+
it('accepts Error constructor', () => {
|
|
98
|
+
const assertion = expect(() => { throw new TypeError() }).Throw(TypeError)
|
|
99
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
describe('toThrow type handling', () => {
|
|
104
|
+
it('accepts no arguments', () => {
|
|
105
|
+
const assertion = expect(() => { throw new Error() }).toThrow()
|
|
106
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('accepts string error message', () => {
|
|
110
|
+
const assertion = expect(() => { throw new Error('test') }).toThrow('test')
|
|
111
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('accepts RegExp pattern', () => {
|
|
115
|
+
const assertion = expect(() => { throw new Error('test') }).toThrow(/test/)
|
|
116
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
it('accepts Error instance', () => {
|
|
120
|
+
const err = new Error('test')
|
|
121
|
+
const assertion = expect(() => { throw err }).toThrow(err)
|
|
122
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
describe('Assertion class internal type safety', () => {
|
|
127
|
+
it('returns correct Assertion type from expect', () => {
|
|
128
|
+
const assertion = expect(42)
|
|
129
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('chains return Assertion type', () => {
|
|
133
|
+
const assertion = expect(42).to.be.a('number')
|
|
134
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
it('negation returns Assertion type', () => {
|
|
138
|
+
const assertion = expect(42).not
|
|
139
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
it('deep flag returns Assertion type', () => {
|
|
143
|
+
const assertion = expect({ a: 1 }).deep
|
|
144
|
+
expectTypeOf(assertion).toEqualTypeOf<Assertion>()
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
describe('Runtime Type Safety', () => {
|
|
150
|
+
describe('instanceof runtime behavior', () => {
|
|
151
|
+
it('works with custom classes at runtime', () => {
|
|
152
|
+
class CustomError extends Error {
|
|
153
|
+
constructor(message: string) {
|
|
154
|
+
super(message)
|
|
155
|
+
this.name = 'CustomError'
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
vitestExpect(() => expect(new CustomError('test')).instanceof(CustomError)).not.toThrow()
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
it('works with inheritance chains', () => {
|
|
162
|
+
vitestExpect(() => expect(new TypeError()).instanceof(Error)).not.toThrow()
|
|
163
|
+
})
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
describe('throw runtime behavior with typed constructors', () => {
|
|
167
|
+
it('works with Error constructor', () => {
|
|
168
|
+
vitestExpect(() =>
|
|
169
|
+
expect(() => { throw new Error('test') }).throw(Error)
|
|
170
|
+
).not.toThrow()
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
it('works with specific error types', () => {
|
|
174
|
+
vitestExpect(() =>
|
|
175
|
+
expect(() => { throw new TypeError('test') }).throw(TypeError)
|
|
176
|
+
).not.toThrow()
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
it('works with Error constructor and message', () => {
|
|
180
|
+
vitestExpect(() =>
|
|
181
|
+
expect(() => { throw new Error('test message') }).throw(Error, /test/)
|
|
182
|
+
).not.toThrow()
|
|
183
|
+
})
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
describe('toBeInstanceOf runtime behavior', () => {
|
|
187
|
+
it('works with built-in types', () => {
|
|
188
|
+
vitestExpect(() => expect([]).toBeInstanceOf(Array)).not.toThrow()
|
|
189
|
+
vitestExpect(() => expect(new Map()).toBeInstanceOf(Map)).not.toThrow()
|
|
190
|
+
vitestExpect(() => expect(new Set()).toBeInstanceOf(Set)).not.toThrow()
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
describe('toThrow runtime behavior', () => {
|
|
195
|
+
it('works with Error type', () => {
|
|
196
|
+
vitestExpect(() =>
|
|
197
|
+
expect(() => { throw new Error('test') }).toThrow(Error)
|
|
198
|
+
).not.toThrow()
|
|
199
|
+
})
|
|
200
|
+
})
|
|
201
|
+
})
|