bupkis 0.6.0 → 0.7.2
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/CHANGELOG.md +35 -0
- package/README.md +33 -30
- package/dist/commonjs/assertion/assertion-async.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion-async.js +4 -11
- package/dist/commonjs/assertion/assertion-async.js.map +1 -1
- package/dist/commonjs/assertion/assertion-sync.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion-sync.js +3 -13
- package/dist/commonjs/assertion/assertion-sync.js.map +1 -1
- package/dist/commonjs/assertion/assertion.d.ts.map +1 -1
- package/dist/commonjs/assertion/assertion.js +3 -3
- package/dist/commonjs/assertion/assertion.js.map +1 -1
- package/dist/commonjs/assertion/create.d.ts.map +1 -1
- package/dist/commonjs/assertion/create.js +13 -12
- package/dist/commonjs/assertion/create.js.map +1 -1
- package/dist/commonjs/assertion/impl/async-parametric.d.ts +2 -2
- package/dist/commonjs/assertion/impl/async-parametric.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/async-parametric.js +5 -48
- package/dist/commonjs/assertion/impl/async-parametric.js.map +1 -1
- package/dist/commonjs/assertion/impl/async.d.ts +4 -4
- package/dist/commonjs/assertion/impl/sync-collection.js +1 -1
- package/dist/commonjs/assertion/impl/sync-collection.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync-parametric.d.ts +2 -2
- package/dist/commonjs/assertion/impl/sync-parametric.d.ts.map +1 -1
- package/dist/commonjs/assertion/impl/sync-parametric.js +14 -5
- package/dist/commonjs/assertion/impl/sync-parametric.js.map +1 -1
- package/dist/commonjs/assertion/impl/sync.d.ts +4 -4
- package/dist/commonjs/assertion/slotify.d.ts.map +1 -1
- package/dist/commonjs/assertion/slotify.js +4 -3
- package/dist/commonjs/assertion/slotify.js.map +1 -1
- package/dist/commonjs/bootstrap.d.ts +4 -4
- package/dist/commonjs/constant.js +7 -1
- package/dist/commonjs/constant.js.map +1 -1
- package/dist/commonjs/error.d.ts +134 -0
- package/dist/commonjs/error.d.ts.map +1 -1
- package/dist/commonjs/error.js +117 -1
- package/dist/commonjs/error.js.map +1 -1
- package/dist/commonjs/expect.d.ts +4 -2
- package/dist/commonjs/expect.d.ts.map +1 -1
- package/dist/commonjs/expect.js +19 -6
- package/dist/commonjs/expect.js.map +1 -1
- package/dist/commonjs/guards.d.ts.map +1 -1
- package/dist/commonjs/guards.js +4 -1
- package/dist/commonjs/guards.js.map +1 -1
- package/dist/commonjs/index.d.ts +6 -5
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +6 -3
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/value-to-schema.d.ts.map +1 -1
- package/dist/commonjs/value-to-schema.js +3 -2
- package/dist/commonjs/value-to-schema.js.map +1 -1
- package/dist/esm/assertion/assertion-async.d.ts.map +1 -1
- package/dist/esm/assertion/assertion-async.js +5 -12
- package/dist/esm/assertion/assertion-async.js.map +1 -1
- package/dist/esm/assertion/assertion-sync.d.ts.map +1 -1
- package/dist/esm/assertion/assertion-sync.js +7 -17
- package/dist/esm/assertion/assertion-sync.js.map +1 -1
- package/dist/esm/assertion/assertion.d.ts.map +1 -1
- package/dist/esm/assertion/assertion.js +6 -6
- package/dist/esm/assertion/assertion.js.map +1 -1
- package/dist/esm/assertion/create.d.ts.map +1 -1
- package/dist/esm/assertion/create.js +13 -12
- package/dist/esm/assertion/create.js.map +1 -1
- package/dist/esm/assertion/impl/async-parametric.d.ts +2 -2
- package/dist/esm/assertion/impl/async-parametric.d.ts.map +1 -1
- package/dist/esm/assertion/impl/async-parametric.js +5 -48
- package/dist/esm/assertion/impl/async-parametric.js.map +1 -1
- package/dist/esm/assertion/impl/async.d.ts +4 -4
- package/dist/esm/assertion/impl/sync-collection.js +1 -1
- package/dist/esm/assertion/impl/sync-collection.js.map +1 -1
- package/dist/esm/assertion/impl/sync-parametric.d.ts +2 -2
- package/dist/esm/assertion/impl/sync-parametric.d.ts.map +1 -1
- package/dist/esm/assertion/impl/sync-parametric.js +14 -5
- package/dist/esm/assertion/impl/sync-parametric.js.map +1 -1
- package/dist/esm/assertion/impl/sync.d.ts +4 -4
- package/dist/esm/assertion/slotify.d.ts.map +1 -1
- package/dist/esm/assertion/slotify.js +4 -3
- package/dist/esm/assertion/slotify.js.map +1 -1
- package/dist/esm/bootstrap.d.ts +4 -4
- package/dist/esm/constant.js +6 -0
- package/dist/esm/constant.js.map +1 -1
- package/dist/esm/error.d.ts +134 -0
- package/dist/esm/error.d.ts.map +1 -1
- package/dist/esm/error.js +110 -1
- package/dist/esm/error.js.map +1 -1
- package/dist/esm/expect.d.ts +4 -2
- package/dist/esm/expect.d.ts.map +1 -1
- package/dist/esm/expect.js +22 -9
- package/dist/esm/expect.js.map +1 -1
- package/dist/esm/guards.d.ts.map +1 -1
- package/dist/esm/guards.js +4 -1
- package/dist/esm/guards.js.map +1 -1
- package/dist/esm/index.d.ts +6 -5
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/value-to-schema.d.ts.map +1 -1
- package/dist/esm/value-to-schema.js +3 -2
- package/dist/esm/value-to-schema.js.map +1 -1
- package/package.json +17 -21
- package/src/assertion/assertion-async.ts +9 -18
- package/src/assertion/assertion-sync.ts +12 -24
- package/src/assertion/assertion.ts +7 -6
- package/src/assertion/create.ts +31 -12
- package/src/assertion/impl/async-parametric.ts +7 -49
- package/src/assertion/impl/sync-collection.ts +1 -1
- package/src/assertion/impl/sync-parametric.ts +19 -5
- package/src/assertion/slotify.ts +4 -3
- package/src/constant.ts +7 -0
- package/src/error.ts +188 -0
- package/src/expect.ts +31 -10
- package/src/guards.ts +4 -1
- package/src/index.ts +2 -1
- package/src/value-to-schema.ts +3 -2
package/dist/commonjs/error.d.ts
CHANGED
|
@@ -6,11 +6,58 @@
|
|
|
6
6
|
* @packageDocumentation
|
|
7
7
|
*/
|
|
8
8
|
import { AssertionError as NodeAssertionError } from 'node:assert';
|
|
9
|
+
import { kBupkisError } from './constant.js';
|
|
10
|
+
/**
|
|
11
|
+
* Options for {@link AssertionImplementationError}
|
|
12
|
+
*
|
|
13
|
+
* @group Error Options
|
|
14
|
+
*/
|
|
15
|
+
export interface AssertionImplementationErrorOptions extends ErrorOptions {
|
|
16
|
+
/**
|
|
17
|
+
* The result returned by an assertion implementation that caused this error.
|
|
18
|
+
*/
|
|
19
|
+
result?: unknown;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Options for {@link InvalidMetadataError}
|
|
23
|
+
*
|
|
24
|
+
* @group Error Options
|
|
25
|
+
*/
|
|
26
|
+
export interface InvalidMetadataErrorOptions extends ErrorOptions {
|
|
27
|
+
/**
|
|
28
|
+
* The invalid metadata.
|
|
29
|
+
*/
|
|
30
|
+
metadata?: unknown;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Options for {@link InvalidSchemaError}
|
|
34
|
+
*
|
|
35
|
+
* @group Error Options
|
|
36
|
+
*/
|
|
37
|
+
export interface InvalidSchemaErrorOptions extends ErrorOptions {
|
|
38
|
+
/**
|
|
39
|
+
* The invalid schema
|
|
40
|
+
*/
|
|
41
|
+
schema?: unknown;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Options for {@link UnknownAssertionError}
|
|
45
|
+
*
|
|
46
|
+
* @group Error Options
|
|
47
|
+
*/
|
|
48
|
+
export interface UnknownAssertionErrorOptions<T extends readonly unknown[]> extends ErrorOptions {
|
|
49
|
+
/**
|
|
50
|
+
* The arguments passed to {@link bupkis!expect | expect} or
|
|
51
|
+
* {@link bupkis!expectAsync | expectAsync} which caused this error.
|
|
52
|
+
*/
|
|
53
|
+
args: T;
|
|
54
|
+
}
|
|
9
55
|
/**
|
|
10
56
|
* _BUPKIS_' s custom `AssertionError` class, which is just a thin wrapper
|
|
11
57
|
* around Node.js' {@link NodeAssertionError AssertionError}.
|
|
12
58
|
*
|
|
13
59
|
* @group Core API
|
|
60
|
+
* @group Errors
|
|
14
61
|
*/
|
|
15
62
|
export declare class AssertionError extends NodeAssertionError {
|
|
16
63
|
name: string;
|
|
@@ -22,12 +69,99 @@ export declare class AssertionError extends NodeAssertionError {
|
|
|
22
69
|
*/
|
|
23
70
|
static isAssertionError(value: unknown): value is AssertionError;
|
|
24
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Base class for all custom errors thrown by <span
|
|
74
|
+
* class="bupkis">BUPKIS</span>.
|
|
75
|
+
*
|
|
76
|
+
* Typically only thrown when it should be impossible to throw.
|
|
77
|
+
*
|
|
78
|
+
* @group Errors
|
|
79
|
+
*/
|
|
80
|
+
export declare class BupkisError extends Error {
|
|
81
|
+
[kBupkisError]: boolean;
|
|
82
|
+
name: string;
|
|
83
|
+
static isBupkisError(err: unknown): err is BupkisError;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Error type used when an assertion implementation throws an error (this likely
|
|
87
|
+
* means there's a bug in the assertion implementation).
|
|
88
|
+
*
|
|
89
|
+
* @group Errors
|
|
90
|
+
*/
|
|
91
|
+
export declare class AssertionImplementationError extends BupkisError {
|
|
92
|
+
readonly code = "ERR_BUPKIS_ASSERTION_IMPL";
|
|
93
|
+
name: string;
|
|
94
|
+
readonly result: unknown;
|
|
95
|
+
constructor(message: string, options?: AssertionImplementationErrorOptions);
|
|
96
|
+
}
|
|
25
97
|
/**
|
|
26
98
|
* Variant of an {@link AssertionError} that is thrown when
|
|
27
99
|
* {@link bupkis!expect.fail} is called.
|
|
100
|
+
*
|
|
101
|
+
* @group Errors
|
|
28
102
|
*/
|
|
29
103
|
export declare class FailAssertionError extends AssertionError {
|
|
30
104
|
name: string;
|
|
31
105
|
static isFailAssertionError(err: unknown): err is FailAssertionError;
|
|
32
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Error type used when assertion metadata is invalid.
|
|
109
|
+
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* This should never be thrown unless someone monkeyed with the metadata
|
|
112
|
+
* registry.
|
|
113
|
+
* @group Errors
|
|
114
|
+
*/
|
|
115
|
+
export declare class InvalidMetadataError extends BupkisError {
|
|
116
|
+
readonly code = "ERR_BUPKIS_INVALID_METADATA";
|
|
117
|
+
readonly metadata?: unknown;
|
|
118
|
+
name: string;
|
|
119
|
+
constructor(message: string, options?: InvalidMetadataErrorOptions);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Thrown from certain assertions when the result of `valueToSchema` is invalid.
|
|
123
|
+
*
|
|
124
|
+
* @group Errors
|
|
125
|
+
*/
|
|
126
|
+
export declare class InvalidSchemaError extends BupkisError {
|
|
127
|
+
readonly code = "ERR_BUPKIS_INVALID_SCHEMA";
|
|
128
|
+
name: string;
|
|
129
|
+
readonly schema?: unknown;
|
|
130
|
+
constructor(message: string, options?: InvalidSchemaErrorOptions);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Thrown when `expect()` is called with something async.
|
|
134
|
+
*
|
|
135
|
+
* @group Errors
|
|
136
|
+
*/
|
|
137
|
+
export declare class UnexpectedAsyncError extends BupkisError {
|
|
138
|
+
readonly code = "ERR_BUPKIS_UNEXPECTED_ASYNC";
|
|
139
|
+
name: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Thrown when we cannot match the parameters to {@link bupkis!expect | expect}
|
|
143
|
+
* or {@link bupkis!expectAsync | expectAsync} to any known assertion.
|
|
144
|
+
*
|
|
145
|
+
* @group Errors
|
|
146
|
+
*/
|
|
147
|
+
export declare class UnknownAssertionError<T extends readonly unknown[]> extends BupkisError {
|
|
148
|
+
readonly args: T;
|
|
149
|
+
readonly code = "ERR_BUPKIS_UNKNOWN_ASSERTION";
|
|
150
|
+
name: string;
|
|
151
|
+
constructor(message: string, options: UnknownAssertionErrorOptions<T>);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Thrown when a value cannot be converted to a schema using `valueToSchema()`.
|
|
155
|
+
*
|
|
156
|
+
* @remarks
|
|
157
|
+
* Currently, this includes the presence of an own property `__proto__` or an
|
|
158
|
+
* empty object (because this will match anything; though maybe we should change
|
|
159
|
+
* that).
|
|
160
|
+
* @group Errors
|
|
161
|
+
*/
|
|
162
|
+
export declare class ValueToSchemaError extends BupkisError {
|
|
163
|
+
readonly code = "ERR_BUPKIS_SATISFACTION";
|
|
164
|
+
name: string;
|
|
165
|
+
constructor(message: string, options?: ErrorOptions);
|
|
166
|
+
}
|
|
33
167
|
//# sourceMappingURL=error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EAEL,YAAY,EAGb,MAAM,eAAe,CAAC;AAGvB;;;;GAIG;AACH,MAAM,WAAW,mCAAoC,SAAQ,YAAY;IACvE;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AACD;;;;GAIG;AACH,MAAM,WAAW,2BAA4B,SAAQ,YAAY;IAC/D;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAA0B,SAAQ,YAAY;IAC7D;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA4B,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,CACxE,SAAQ,YAAY;IACpB;;;OAGG;IACH,IAAI,EAAE,CAAC,CAAC;CACT;AAED;;;;;;GAMG;AACH,qBAAa,cAAe,SAAQ,kBAAkB;IAM3C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ChC,CAAC,SAAS,SAAS,OAAO,EAAE,CAC5B,SAAQ,WAAW;IACnB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAEjB,QAAQ,CAAC,IAAI,kCAAkC;IAEtC,IAAI,SAA2B;gBAE5B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,4BAA4B,CAAC,CAAC,CAAC;CAKtE;AAED;;;;;;;;GAQG;AACH,qBAAa,kBAAmB,SAAQ,WAAW;IACjD,QAAQ,CAAC,IAAI,6BAA6B;IAEjC,IAAI,SAAuB;gBAExB,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB;CAGxD"}
|
package/dist/commonjs/error.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.NegatedAssertionError = exports.FailAssertionError = exports.AssertionError = void 0;
|
|
10
|
+
exports.ValueToSchemaError = exports.UnknownAssertionError = exports.UnexpectedAsyncError = exports.NegatedAssertionError = exports.InvalidSchemaError = exports.InvalidMetadataError = exports.FailAssertionError = exports.AssertionImplementationError = exports.BupkisError = exports.AssertionError = void 0;
|
|
11
11
|
const node_assert_1 = require("node:assert");
|
|
12
12
|
const constant_js_1 = require("./constant.js");
|
|
13
13
|
const guards_js_1 = require("./guards.js");
|
|
@@ -16,6 +16,7 @@ const guards_js_1 = require("./guards.js");
|
|
|
16
16
|
* around Node.js' {@link NodeAssertionError AssertionError}.
|
|
17
17
|
*
|
|
18
18
|
* @group Core API
|
|
19
|
+
* @group Errors
|
|
19
20
|
*/
|
|
20
21
|
class AssertionError extends node_assert_1.AssertionError {
|
|
21
22
|
/**
|
|
@@ -35,9 +36,44 @@ class AssertionError extends node_assert_1.AssertionError {
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
exports.AssertionError = AssertionError;
|
|
39
|
+
/**
|
|
40
|
+
* Base class for all custom errors thrown by <span
|
|
41
|
+
* class="bupkis">BUPKIS</span>.
|
|
42
|
+
*
|
|
43
|
+
* Typically only thrown when it should be impossible to throw.
|
|
44
|
+
*
|
|
45
|
+
* @group Errors
|
|
46
|
+
*/
|
|
47
|
+
class BupkisError extends Error {
|
|
48
|
+
[constant_js_1.kBupkisError] = true;
|
|
49
|
+
name = 'BupkisError';
|
|
50
|
+
static isBupkisError(err) {
|
|
51
|
+
return (0, guards_js_1.isA)(err, Error) && Object.hasOwn(err, constant_js_1.kBupkisError);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.BupkisError = BupkisError;
|
|
55
|
+
/**
|
|
56
|
+
* Error type used when an assertion implementation throws an error (this likely
|
|
57
|
+
* means there's a bug in the assertion implementation).
|
|
58
|
+
*
|
|
59
|
+
* @group Errors
|
|
60
|
+
*/
|
|
61
|
+
class AssertionImplementationError extends BupkisError {
|
|
62
|
+
code = 'ERR_BUPKIS_ASSERTION_IMPL';
|
|
63
|
+
name = 'AssertionImplementationError';
|
|
64
|
+
result;
|
|
65
|
+
constructor(message, options = {}) {
|
|
66
|
+
const { result, ...rest } = options;
|
|
67
|
+
super(message, rest);
|
|
68
|
+
this.result = result;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.AssertionImplementationError = AssertionImplementationError;
|
|
38
72
|
/**
|
|
39
73
|
* Variant of an {@link AssertionError} that is thrown when
|
|
40
74
|
* {@link bupkis!expect.fail} is called.
|
|
75
|
+
*
|
|
76
|
+
* @group Errors
|
|
41
77
|
*/
|
|
42
78
|
class FailAssertionError extends AssertionError {
|
|
43
79
|
/**
|
|
@@ -51,10 +87,46 @@ class FailAssertionError extends AssertionError {
|
|
|
51
87
|
}
|
|
52
88
|
}
|
|
53
89
|
exports.FailAssertionError = FailAssertionError;
|
|
90
|
+
/**
|
|
91
|
+
* Error type used when assertion metadata is invalid.
|
|
92
|
+
*
|
|
93
|
+
* @remarks
|
|
94
|
+
* This should never be thrown unless someone monkeyed with the metadata
|
|
95
|
+
* registry.
|
|
96
|
+
* @group Errors
|
|
97
|
+
*/
|
|
98
|
+
class InvalidMetadataError extends BupkisError {
|
|
99
|
+
code = 'ERR_BUPKIS_INVALID_METADATA';
|
|
100
|
+
metadata;
|
|
101
|
+
name = 'InvalidMetadataError';
|
|
102
|
+
constructor(message, options = {}) {
|
|
103
|
+
const { metadata, ...rest } = options;
|
|
104
|
+
super(message, rest);
|
|
105
|
+
this.metadata = metadata;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.InvalidMetadataError = InvalidMetadataError;
|
|
109
|
+
/**
|
|
110
|
+
* Thrown from certain assertions when the result of `valueToSchema` is invalid.
|
|
111
|
+
*
|
|
112
|
+
* @group Errors
|
|
113
|
+
*/
|
|
114
|
+
class InvalidSchemaError extends BupkisError {
|
|
115
|
+
code = 'ERR_BUPKIS_INVALID_SCHEMA';
|
|
116
|
+
name = 'InvalidSchemaError';
|
|
117
|
+
schema;
|
|
118
|
+
constructor(message, options = {}) {
|
|
119
|
+
const { schema, ...rest } = options;
|
|
120
|
+
super(message, rest);
|
|
121
|
+
this.schema = schema;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.InvalidSchemaError = InvalidSchemaError;
|
|
54
125
|
/**
|
|
55
126
|
* Error type used internally to catch failed negated assertions.
|
|
56
127
|
*
|
|
57
128
|
* @internal
|
|
129
|
+
* @group Errors
|
|
58
130
|
*/
|
|
59
131
|
class NegatedAssertionError extends AssertionError {
|
|
60
132
|
[constant_js_1.kBupkisNegatedAssertionError] = true;
|
|
@@ -65,4 +137,48 @@ class NegatedAssertionError extends AssertionError {
|
|
|
65
137
|
}
|
|
66
138
|
}
|
|
67
139
|
exports.NegatedAssertionError = NegatedAssertionError;
|
|
140
|
+
/**
|
|
141
|
+
* Thrown when `expect()` is called with something async.
|
|
142
|
+
*
|
|
143
|
+
* @group Errors
|
|
144
|
+
*/
|
|
145
|
+
class UnexpectedAsyncError extends BupkisError {
|
|
146
|
+
code = 'ERR_BUPKIS_UNEXPECTED_ASYNC';
|
|
147
|
+
name = 'UnexpectedAsyncError';
|
|
148
|
+
}
|
|
149
|
+
exports.UnexpectedAsyncError = UnexpectedAsyncError;
|
|
150
|
+
/**
|
|
151
|
+
* Thrown when we cannot match the parameters to {@link bupkis!expect | expect}
|
|
152
|
+
* or {@link bupkis!expectAsync | expectAsync} to any known assertion.
|
|
153
|
+
*
|
|
154
|
+
* @group Errors
|
|
155
|
+
*/
|
|
156
|
+
class UnknownAssertionError extends BupkisError {
|
|
157
|
+
args;
|
|
158
|
+
code = 'ERR_BUPKIS_UNKNOWN_ASSERTION';
|
|
159
|
+
name = 'UnknownAssertionError';
|
|
160
|
+
constructor(message, options) {
|
|
161
|
+
const { args, ...rest } = options;
|
|
162
|
+
super(message, rest);
|
|
163
|
+
this.args = args;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.UnknownAssertionError = UnknownAssertionError;
|
|
167
|
+
/**
|
|
168
|
+
* Thrown when a value cannot be converted to a schema using `valueToSchema()`.
|
|
169
|
+
*
|
|
170
|
+
* @remarks
|
|
171
|
+
* Currently, this includes the presence of an own property `__proto__` or an
|
|
172
|
+
* empty object (because this will match anything; though maybe we should change
|
|
173
|
+
* that).
|
|
174
|
+
* @group Errors
|
|
175
|
+
*/
|
|
176
|
+
class ValueToSchemaError extends BupkisError {
|
|
177
|
+
code = 'ERR_BUPKIS_SATISFACTION';
|
|
178
|
+
name = 'SatisfactionError';
|
|
179
|
+
constructor(message, options = {}) {
|
|
180
|
+
super(message, options);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.ValueToSchemaError = ValueToSchemaError;
|
|
68
184
|
//# sourceMappingURL=error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,6CAAmE;AAEnE,+
|
|
1
|
+
{"version":3,"file":"error.js","s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4B,CAAC,CACjD,CAAC;IACJ,CAAC;CACF;AAXD,sDAWC;AAED;;;;GAIG;AACH,MAAa,oBAAqB,SAAQ,WAAW;IAC1C,IAAI,GAAG,6BAA6B,CAAC;IAErC,IAAI,GAAG,sBAAsB,CAAC;CACxC;AAJD,oDAIC;AAED;;;;;GAKG;AACH,MAAa,qBAEX,SAAQ,WAAW;IACV,IAAI,CAAI;IAER,IAAI,GAAG,8BAA8B,CAAC;IAEtC,IAAI,GAAG,uBAAuB,CAAC;IAExC,YAAY,OAAe,EAAE,OAAwC;QACnE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;QAClC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAdD,sDAcC;AAED;;;;;;;;GAQG;AACH,MAAa,kBAAmB,SAAQ,WAAW;IACxC,IAAI,GAAG,yBAAyB,CAAC;IAEjC,IAAI,GAAG,mBAAmB,CAAC;IAEpC,YAAY,OAAe,EAAE,UAAwB,EAAE;QACrD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF;AARD,gDAQC"}
|
|
@@ -128,9 +128,11 @@ export declare function createExpectSyncFunction<Assertions extends AnySyncAsser
|
|
|
128
128
|
*/
|
|
129
129
|
export declare function createExpectSyncFunction<Assertions extends AnySyncAssertions>(assertions: Assertions): ExpectFunction<Assertions>;
|
|
130
130
|
/**
|
|
131
|
-
* Used by a {@link UseFn} to create base properties of
|
|
132
|
-
* {@link ExpectAsync} functions.
|
|
131
|
+
* Used by a {@link UseFn} to create base properties of {@link Expect}.
|
|
133
132
|
*/
|
|
134
133
|
export declare function createBaseExpect<T extends AnySyncAssertions, U extends AnyAsyncAssertions>(syncAssertions: T, asyncAssertions: U, type: 'sync'): ExpectSyncProps<T, U>;
|
|
134
|
+
/**
|
|
135
|
+
* Used by a {@link UseFn} to create base properties of {@link ExpectAsync}.
|
|
136
|
+
*/
|
|
135
137
|
export declare function createBaseExpect<T extends AnySyncAssertions, U extends AnyAsyncAssertions>(syncAssertions: T, asyncAssertions: U, type: 'async'): ExpectAsyncProps<U, T>;
|
|
136
138
|
//# sourceMappingURL=expect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../src/expect.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,kBAAkB,EAEvB,KAAK,iBAAiB,EASvB,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../src/expect.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,kBAAkB,EAEvB,KAAK,iBAAiB,EASvB,MAAM,gCAAgC,CAAC;AASxC,OAAO,EACL,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,eAAe,EAIrB,MAAM,YAAY,CAAC;AAKpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,yBAAyB,CACvC,CAAC,SAAS,kBAAkB,EAC5B,CAAC,SAAS,WAAW,CAAC,kBAAkB,CAAC,EACzC,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,kBAAkB,EACpE,UAAU,EAAE,CAAC,GACZ,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAoH1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,SAAS,iBAAiB,EACpC,YAAY,SAAS,MAAM,CAAC,iBAAiB,CAAC,EAE9C,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,YAAY,GACnB,cAAc,CAAC,UAAU,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,SAAS,iBAAiB,EAC3E,UAAU,EAAE,UAAU,GACrB,cAAc,CAAC,UAAU,CAAC,CAAC;AAkT9B;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,CAAC,SAAS,iBAAiB,EAC3B,CAAC,SAAS,kBAAkB,EAC5B,cAAc,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9E;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,CAAC,SAAS,iBAAiB,EAC3B,CAAC,SAAS,kBAAkB,EAC5B,cAAc,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
|
package/dist/commonjs/expect.js
CHANGED
|
@@ -76,7 +76,7 @@ const debug = (0, debug_1.default)('bupkis:expect');
|
|
|
76
76
|
* @see {@link ExpectAsync} for the main expectAsync interface
|
|
77
77
|
*/
|
|
78
78
|
function createExpectAsyncFunction(assertions, expect) {
|
|
79
|
-
debug('Creating expectAsync function with %d assertions', assertions.length + (expect?.assertions.length ?? 0));
|
|
79
|
+
debug('ℹ Creating expectAsync function with %d new assertions and %d existing assertions (%d total)', assertions.length, expect?.assertions.length ?? 0, assertions.length + (expect?.assertions.length ?? 0));
|
|
80
80
|
const expectAsyncFunction = async (...args) => {
|
|
81
81
|
await Promise.resolve();
|
|
82
82
|
const [isNegated, processedArgs] = maybeProcessNegation(args);
|
|
@@ -155,7 +155,7 @@ function createExpectAsyncFunction(assertions, expect) {
|
|
|
155
155
|
* @see {@link Expect} for the main expect interface
|
|
156
156
|
*/
|
|
157
157
|
function createExpectSyncFunction(assertions, expect) {
|
|
158
|
-
debug('Creating expect function with %d assertions', assertions.length + (expect?.assertions.length ?? 0));
|
|
158
|
+
debug('ℹ Creating expect function with %d new assertions and %d existing assertions (%d total)', assertions.length, expect?.assertions.length ?? 0, assertions.length + (expect?.assertions.length ?? 0));
|
|
159
159
|
const expectFunction = (...args) => {
|
|
160
160
|
const [isNegated, processedArgs] = maybeProcessNegation(args);
|
|
161
161
|
const candidates = [];
|
|
@@ -196,7 +196,6 @@ const execute = (assertion, parsedValues, args, stackStartFn, isNegated, parseRe
|
|
|
196
196
|
return assertion.execute(parsedValues, args, stackStartFn, parseResult);
|
|
197
197
|
}
|
|
198
198
|
try {
|
|
199
|
-
debug('Executing negated assertion: %s', assertion);
|
|
200
199
|
const result = assertion.execute(parsedValues, args, stackStartFn, parseResult);
|
|
201
200
|
if ((0, guards_js_1.isAssertionFailure)(result)) {
|
|
202
201
|
throw new error_js_1.NegatedAssertionError({
|
|
@@ -245,7 +244,6 @@ const executeAsync = async (assertion, parsedValues, args, stackStartFn, isNegat
|
|
|
245
244
|
return assertion.executeAsync(parsedValues, args, stackStartFn, parseResult);
|
|
246
245
|
}
|
|
247
246
|
try {
|
|
248
|
-
debug('Executing negated async assertion: %s', assertion);
|
|
249
247
|
await assertion.executeAsync(parsedValues, args, stackStartFn, parseResult);
|
|
250
248
|
// If we reach here, the assertion passed but we expected it to fail
|
|
251
249
|
throw new error_js_1.NegatedAssertionError({
|
|
@@ -269,6 +267,10 @@ const executeAsync = async (assertion, parsedValues, args, stackStartFn, isNegat
|
|
|
269
267
|
}
|
|
270
268
|
};
|
|
271
269
|
/**
|
|
270
|
+
* Processes negation keywords in the arguments and returns whether negation is
|
|
271
|
+
* requested along with arguments stripped of the leading negation (to enable
|
|
272
|
+
* assertion matching).
|
|
273
|
+
*
|
|
272
274
|
* @internal
|
|
273
275
|
*/
|
|
274
276
|
const maybeProcessNegation = (args) => {
|
|
@@ -284,12 +286,16 @@ const maybeProcessNegation = (args) => {
|
|
|
284
286
|
return [isNegated, processedArgs];
|
|
285
287
|
};
|
|
286
288
|
/**
|
|
289
|
+
* Throws an error indicating that no valid assertion could be found for the
|
|
290
|
+
* provided arguments.
|
|
291
|
+
*
|
|
292
|
+
* @param args The arguments that were passed to the expect function
|
|
287
293
|
* @internal
|
|
288
294
|
*/
|
|
289
295
|
const throwInvalidParametersError = (args) => {
|
|
290
296
|
const inspectedArgs = (0, util_1.inspect)(args, { depth: 1 });
|
|
291
|
-
debug(
|
|
292
|
-
throw new
|
|
297
|
+
debug('Invalid arguments. No assertion matched: %s', inspectedArgs);
|
|
298
|
+
throw new error_js_1.UnknownAssertionError(`Invalid arguments. No assertion matched: ${inspectedArgs}`, { args });
|
|
293
299
|
};
|
|
294
300
|
/**
|
|
295
301
|
* Detects if an assertion phrase starts with "not " and returns the cleaned
|
|
@@ -310,9 +316,16 @@ const detectNegation = (phrase) => {
|
|
|
310
316
|
isNegated: false,
|
|
311
317
|
};
|
|
312
318
|
};
|
|
319
|
+
/**
|
|
320
|
+
* {@inheritdoc FailFn}
|
|
321
|
+
*/
|
|
313
322
|
const fail = (reason) => {
|
|
314
323
|
throw new error_js_1.FailAssertionError({ message: reason });
|
|
315
324
|
};
|
|
325
|
+
/**
|
|
326
|
+
* Used by a {@link UseFn} to create base properties of {@link Expect} or
|
|
327
|
+
* {@link ExpectAsync}.
|
|
328
|
+
*/
|
|
316
329
|
function createBaseExpect(syncAssertions, asyncAssertions, type) {
|
|
317
330
|
return type === 'sync'
|
|
318
331
|
? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expect.js","sourceRoot":"","sources":["../../src/expect.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"expect.js","sourceRoot":"","sources":["../../src/expect.ts"],"names":[],"mappings":";;;;;AA6KA,8DAkDC;AAgID,4DAiDC;AA4ND,4CAmBC;AA/nBD,kDAAgC;AA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CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,UAAU,EACzE,OAAO,OAAO,KACb,KAAK,IAAI,gBAAgB,CAAC,OAAO,CAEnC,CAAC"}
|
package/dist/commonjs/guards.js
CHANGED
|
@@ -57,7 +57,10 @@ exports.isZodPromise = isZodPromise;
|
|
|
57
57
|
* @param value - Value to test
|
|
58
58
|
* @returns `true` if the value is promise-like, `false` otherwise
|
|
59
59
|
*/
|
|
60
|
-
const isPromiseLike = (value) => (0, exports.isObject)(value) &&
|
|
60
|
+
const isPromiseLike = (value) => (0, exports.isObject)(value) &&
|
|
61
|
+
'then' in value &&
|
|
62
|
+
(0, exports.isFunction)(value.then) &&
|
|
63
|
+
value.then.length > 0;
|
|
61
64
|
exports.isPromiseLike = isPromiseLike;
|
|
62
65
|
/**
|
|
63
66
|
* Returns `true` if the given value is a constructable function (i.e., a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/guards.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAwCH,8BAeC;AApDD,+BAA2B;AAS3B,+CAA0C;AA4B1C,SAAgB,SAAS,CACvB,KAAc,EACd,IAAQ;IAER,MAAM,OAAO,GACX,IAAA,gBAAQ,EAAC,KAAK,CAAC;QACf,KAAK,IAAI,KAAK;QACd,CAAC,CAAC,KAAK,CAAC,GAAG;QACX,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ;QAC7B,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC;IAEtB,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAEpC,OAAQ,KAAmB,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACI,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAgC,EAAE;IACvE,OAAO,OAAO,KAAK,KAAK,QAAQ,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,CAAC,KAAoB,EAAmB,EAAE,CACvE,IAAA,gBAAQ,EAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AADlC,QAAA,eAAe,mBACmB;AAE/C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACI,MAAM,GAAG,GAAG,CACjB,KAAc,EACd,IAAO,EACmB,EAAE;IAC5B,OAAO,IAAA,uBAAe,EAAC,KAAK,CAAC,IAAI,KAAK,YAAY,IAAI,CAAC;AACzD,CAAC,CAAC;AALW,QAAA,GAAG,OAKd;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACI,MAAM,OAAO,GAAG,CAAC,KAAc,EAAkB,EAAE,CAAC,IAAA,WAAG,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAAhE,QAAA,OAAO,WAAyD;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,MAAM,kBAAkB,GAAG,CAChC,KAAc,EACsB,EAAE;IACtC,OAAO,IAAA,kBAAU,EAAC,KAAK,CAAC,IAAI,uBAAS,IAAI,KAAK,IAAI,KAAK,CAAC,uBAAS,CAAC,KAAK,IAAI,CAAC;AAC9E,CAAC,CAAC;AAJW,QAAA,kBAAkB,sBAI7B"}
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
import { z } from 'zod/v4';
|
|
17
17
|
export * as assertions from './assertion/impl/index.js';
|
|
18
18
|
export { expect, expectAsync } from './bootstrap.js';
|
|
19
|
-
export
|
|
19
|
+
export * from './error.js';
|
|
20
|
+
export * as schema from './schema.js';
|
|
20
21
|
/**
|
|
21
22
|
* Re-export of most (all?) types defined within <span
|
|
22
23
|
* class="bupkis">Bupkis</span>.
|
|
@@ -193,9 +194,9 @@ use: import("./types.js").UseFn<readonly [import("./types.js").AssertionFunction
|
|
|
193
194
|
actual: string;
|
|
194
195
|
expected: string;
|
|
195
196
|
message: string;
|
|
196
|
-
} | undefined, readonly [z.ZodString, import("./types.js").PhraseLiteralChoiceSlot<readonly ["includes", "contains", "to include", "to contain"]>, z.ZodString]>, import("./types.js").AssertionFunctionSync<readonly [z.ZodString, "to match", z.ZodCustom<RegExp, RegExp>], (subject: string, regex: RegExp) => boolean, readonly [z.ZodString, import("./types.js").PhraseLiteralSlot<"to match">, z.ZodCustom<RegExp, RegExp>]>, import("./types.js").AssertionFunctionSync<readonly [z.ZodNonOptional<z.ZodObject<{}, z.core.$loose>>, readonly ["to satisfy", "to be like"], z.ZodAny], (_subject: {
|
|
197
|
+
} | undefined, readonly [z.ZodString, import("./types.js").PhraseLiteralChoiceSlot<readonly ["includes", "contains", "to include", "to contain"]>, z.ZodString]>, import("./types.js").AssertionFunctionSync<readonly [z.ZodString, "to match", z.ZodCustom<RegExp, RegExp>], (subject: string, regex: RegExp) => boolean, readonly [z.ZodString, import("./types.js").PhraseLiteralSlot<"to match">, z.ZodCustom<RegExp, RegExp>]>, import("./types.js").AssertionFunctionSync<readonly [z.ZodNonOptional<z.ZodObject<{}, z.core.$loose>>, readonly ["to satisfy", "to be like", "satisfies"], z.ZodAny], (_subject: {
|
|
197
198
|
[x: string]: unknown;
|
|
198
|
-
}, shape: any) => z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>, readonly [z.ZodNonOptional<z.ZodObject<{}, z.core.$loose>>, import("./types.js").PhraseLiteralChoiceSlot<readonly ["to satisfy", "to be like"]>, z.ZodAny]>, import("./types.js").AssertionFunctionSync<readonly [z.ZodUnion<readonly [z.ZodArray<z.ZodUnknown>, z.ZodTuple<[z.ZodUnknown], z.ZodUnknown>, z.ZodObject<{
|
|
199
|
+
}, shape: any) => z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>, readonly [z.ZodNonOptional<z.ZodObject<{}, z.core.$loose>>, import("./types.js").PhraseLiteralChoiceSlot<readonly ["to satisfy", "to be like", "satisfies"]>, z.ZodAny]>, import("./types.js").AssertionFunctionSync<readonly [z.ZodUnion<readonly [z.ZodArray<z.ZodUnknown>, z.ZodTuple<[z.ZodUnknown], z.ZodUnknown>, z.ZodObject<{
|
|
199
200
|
length: z.ZodNumber;
|
|
200
201
|
}, z.core.$loose>]>, readonly ["to satisfy", "to be like"], z.ZodAny], (_subject: unknown[] | [unknown, ...unknown[]] | {
|
|
201
202
|
[x: string]: unknown;
|
|
@@ -238,11 +239,11 @@ use: import("./types.js").UseFn<readonly [import("./types.js").AssertionFunction
|
|
|
238
239
|
actual: string;
|
|
239
240
|
expect: string;
|
|
240
241
|
message: string;
|
|
241
|
-
} | undefined>, readonly [z.ZodCustom<PromiseLike<unknown>, PromiseLike<unknown>>, import("./types.js").PhraseLiteralChoiceSlot<readonly ["to reject with error satisfying"]>, z.ZodAny]>, import("./types.js").AssertionFunctionAsync<readonly [z.ZodCustom<PromiseLike<unknown>, PromiseLike<unknown>>, readonly ["to fulfill with value satisfying", "to resolve with value satisfying"], z.ZodAny], (promise: PromiseLike<unknown>, param: any) => Promise<z.ZodError<
|
|
242
|
+
} | undefined>, readonly [z.ZodCustom<PromiseLike<unknown>, PromiseLike<unknown>>, import("./types.js").PhraseLiteralChoiceSlot<readonly ["to reject with error satisfying"]>, z.ZodAny]>, import("./types.js").AssertionFunctionAsync<readonly [z.ZodCustom<PromiseLike<unknown>, PromiseLike<unknown>>, readonly ["to fulfill with value satisfying", "to resolve with value satisfying"], z.ZodAny], (promise: PromiseLike<unknown>, param: any) => Promise<z.ZodError<any> | {
|
|
242
243
|
actual: unknown;
|
|
243
244
|
expect: string;
|
|
244
245
|
message: string;
|
|
245
|
-
} | undefined>, readonly [z.ZodCustom<PromiseLike<unknown>, PromiseLike<unknown>>, import("./types.js").PhraseLiteralChoiceSlot<readonly ["to fulfill with value satisfying", "to resolve with value satisfying"]>, z.ZodAny]>, import("./types.js").AssertionFunctionAsync<readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, readonly ["to fulfill with value satisfying", "to resolve with value satisfying"], z.ZodAny], (subject: (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, param: any) => Promise<z.ZodError<
|
|
246
|
+
} | undefined>, readonly [z.ZodCustom<PromiseLike<unknown>, PromiseLike<unknown>>, import("./types.js").PhraseLiteralChoiceSlot<readonly ["to fulfill with value satisfying", "to resolve with value satisfying"]>, z.ZodAny]>, import("./types.js").AssertionFunctionAsync<readonly [z.ZodCustom<(...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown>, readonly ["to fulfill with value satisfying", "to resolve with value satisfying"], z.ZodAny], (subject: (...args: import("./types.js").MutableOrReadonly<unknown[]>) => unknown, param: any) => Promise<z.ZodError<any> | {
|
|
246
247
|
actual: string;
|
|
247
248
|
expect: string;
|
|
248
249
|
message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAG3B,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACrD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAG3B,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACrD,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC;;;;;;;;;GASG;AACH,YAAY,KAAK,KAAK,MAAM,YAAY,CAAC;AAEzC;;;GAGG;AACH,OAAO,EAAE,CAAC,EAAE,CAAC;AAEb;;GAEG;AACH,YAAY,EACV,gBAAgB,EAChB,MAAM,EACN,iBAAiB,EACjB,sBAAsB,EACtB,MAAM,EACN,WAAW,EACX,QAAQ,EACR,aAAa,EACb,MAAM,EACN,OAAO,EACP,KAAK,GACN,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AAC5D,QAAA;AACE;;;;;;;;;GASG;AACH,eAAe;AACf;;;;;;;;;GASG;AACH,oBAAoB;AACpB;;;;;;GAMG;AACH,IAAI;AACJ;;;;;;GAMG;AACH,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sUAEgB,CAAC"}
|
package/dist/commonjs/index.js
CHANGED
|
@@ -47,8 +47,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
47
47
|
return result;
|
|
48
48
|
};
|
|
49
49
|
})();
|
|
50
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
51
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
52
|
+
};
|
|
50
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
exports.use = exports.fail = exports.createAsyncAssertion = exports.createAssertion = exports.z = exports.
|
|
54
|
+
exports.use = exports.fail = exports.createAsyncAssertion = exports.createAssertion = exports.z = exports.schema = exports.expectAsync = exports.expect = exports.assertions = void 0;
|
|
52
55
|
const v4_1 = require("zod/v4");
|
|
53
56
|
Object.defineProperty(exports, "z", { enumerable: true, get: function () { return v4_1.z; } });
|
|
54
57
|
const bootstrap_js_1 = require("./bootstrap.js");
|
|
@@ -56,8 +59,8 @@ exports.assertions = __importStar(require("./assertion/impl/index.js"));
|
|
|
56
59
|
var bootstrap_js_2 = require("./bootstrap.js");
|
|
57
60
|
Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return bootstrap_js_2.expect; } });
|
|
58
61
|
Object.defineProperty(exports, "expectAsync", { enumerable: true, get: function () { return bootstrap_js_2.expectAsync; } });
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
__exportStar(require("./error.js"), exports);
|
|
63
|
+
exports.schema = __importStar(require("./schema.js"));
|
|
61
64
|
const {
|
|
62
65
|
/**
|
|
63
66
|
* The main factory function for creating asynchronous assertions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+BAA2B;AAwBlB,kFAxBA,MAAC,OAwBA;AAtBV,iDAA6D;AAC7D,wEAAwD;AACxD,+CAAqD;AAA5C,sGAAA,MAAM,OAAA;AAAE,2GAAA,WAAW,OAAA;AAC5B,6CAA2B;AAC3B,sDAAsC;AAqCtC,MAAM;AACJ;;;;;;;;;GASG;AACH,eAAe;AACf;;;;;;;;;GASG;AACH,oBAAoB;AACpB;;;;;;GAMG;AACH,IAAI;AACJ;;;;;;GAMG;AACH,GAAG,EACH,GAAG,KAAK,EACT,GAAG,qBAAiB,CAAC;AAzCb,0CAAe;AAAE,oDAAoB;AAAE,oBAAI;AAAE,kBAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value-to-schema.d.ts","sourceRoot":"","sources":["../../src/value-to-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"value-to-schema.d.ts","sourceRoot":"","sources":["../../src/value-to-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAa3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,eAAO,MAAM,aAAa,GACxB,OAAO,OAAO,EACd,UAAS,oBAAyB,EAClC,yBAA+B,KAC9B,CAAC,CAAC,OAAO,CAAC,GAAG,CA2Uf,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,oBAAoB;IAQnC;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC;;;;;;EAMH,CAAC;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC;;;;;;EAMH,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.valueToSchemaOptionsForDeepEqual = exports.valueToSchemaOptionsForSatisfies = exports.valueToSchema = void 0;
|
|
4
4
|
const v4_1 = require("zod/v4");
|
|
5
|
+
const error_js_1 = require("./error.js");
|
|
5
6
|
const guards_js_1 = require("./guards.js");
|
|
6
7
|
const schema_js_1 = require("./schema.js");
|
|
7
8
|
/**
|
|
@@ -75,7 +76,7 @@ const valueToSchema = (value, options = {}, visited = new WeakSet()) => {
|
|
|
75
76
|
if ((0, guards_js_1.isExpectItExecutor)(value)) {
|
|
76
77
|
// Only allow nested assertions when strict is false (e.g., "to satisfy" semantics)
|
|
77
78
|
if (strict) {
|
|
78
|
-
throw new
|
|
79
|
+
throw new error_js_1.ValueToSchemaError('ExpectItExecutor (expect.it) functions are not allowed in strict mode. ' +
|
|
79
80
|
'Use "to satisfy" assertions for nested expectations.');
|
|
80
81
|
}
|
|
81
82
|
// Return a schema that executes the ExpectItExecutor when validated
|
|
@@ -110,7 +111,7 @@ const valueToSchema = (value, options = {}, visited = new WeakSet()) => {
|
|
|
110
111
|
try {
|
|
111
112
|
// Check for objects with own __proto__ property - these can cause unexpected behavior
|
|
112
113
|
if (Object.hasOwn(value, '__proto__')) {
|
|
113
|
-
throw new
|
|
114
|
+
throw new error_js_1.ValueToSchemaError('Objects with an own "__proto__" property are not supported by valueToSchema');
|
|
114
115
|
}
|
|
115
116
|
// Handle built-in object types
|
|
116
117
|
if (value instanceof Date) {
|