@rcompat/test 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/private/Assert.d.ts +1 -1
- package/lib/private/Assert.js +11 -5
- package/lib/private/E.d.ts +3 -2
- package/package.json +3 -3
package/lib/private/Assert.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export default class Assert<const Actual> {
|
|
|
16
16
|
undefined(): this;
|
|
17
17
|
defined(): this;
|
|
18
18
|
instance(expected: UnknownFunction): this;
|
|
19
|
-
throws(expected
|
|
19
|
+
throws(expected: string | (new (...args: any[]) => Error)): this;
|
|
20
20
|
tries(): this;
|
|
21
21
|
pass(): void;
|
|
22
22
|
fail<const Expected extends Not<Equals<Actual, Expected>> extends true ? unknown : "was supposed to fail but didn't">(): void;
|
package/lib/private/Assert.js
CHANGED
|
@@ -80,12 +80,17 @@ export default class Assert {
|
|
|
80
80
|
this.#failed("[did not throw]");
|
|
81
81
|
}
|
|
82
82
|
catch (error) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
if (typeof expected === "string") {
|
|
84
|
+
const code = E(error).code;
|
|
85
|
+
code === expected
|
|
86
|
+
? this.#passed()
|
|
87
|
+
: this.#failed(expected, code ?? "[no code]");
|
|
86
88
|
}
|
|
87
89
|
else {
|
|
88
|
-
|
|
90
|
+
error instanceof expected
|
|
91
|
+
? this.#passed()
|
|
92
|
+
: this.#failed(expected.name, error?.constructor?.name
|
|
93
|
+
?? "[unknown]");
|
|
89
94
|
}
|
|
90
95
|
}
|
|
91
96
|
return this;
|
|
@@ -96,7 +101,8 @@ export default class Assert {
|
|
|
96
101
|
this.#passed();
|
|
97
102
|
}
|
|
98
103
|
catch (error) {
|
|
99
|
-
|
|
104
|
+
const { code, message } = E(error);
|
|
105
|
+
this.#failed(`${code ?? message}`, "[did not throw]");
|
|
100
106
|
}
|
|
101
107
|
return this;
|
|
102
108
|
}
|
package/lib/private/E.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
type
|
|
1
|
+
type EncodedError = {
|
|
2
2
|
message: string;
|
|
3
|
+
code?: string;
|
|
3
4
|
};
|
|
4
|
-
declare const _default: (error: unknown) =>
|
|
5
|
+
declare const _default: (error: unknown) => EncodedError;
|
|
5
6
|
export default _default;
|
|
6
7
|
//# sourceMappingURL=E.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rcompat/test",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Standard library testing",
|
|
5
5
|
"bugs": "https://github.com/rcompat/rcompat/issues",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"directory": "packages/test"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@rcompat/fs": "^0.
|
|
19
|
-
"@rcompat/type": "^0.
|
|
18
|
+
"@rcompat/fs": "^0.27.1",
|
|
19
|
+
"@rcompat/type": "^0.10.0"
|
|
20
20
|
},
|
|
21
21
|
"type": "module",
|
|
22
22
|
"imports": {
|