@ark/attest 0.41.2 → 0.41.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/out/assert/assertions.js +37 -14
- package/out/bench/baseline.js +8 -2
- package/out/config.d.ts +2 -1
- package/package.json +5 -5
package/out/assert/assertions.js
CHANGED
|
@@ -41,24 +41,47 @@ export const versionableAssertion = (fn) => (expected, actual, ctx) => {
|
|
|
41
41
|
const unversionedAssertEquals = (expected, actual, ctx) => {
|
|
42
42
|
if (expected === actual)
|
|
43
43
|
return;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
try {
|
|
45
|
+
if (typeof expected === "object" &&
|
|
46
|
+
expected !== null &&
|
|
47
|
+
typeof actual === "object" &&
|
|
48
|
+
actual !== null) {
|
|
49
|
+
if (expected.constructor === actual.constructor)
|
|
50
|
+
assert.deepStrictEqual(actual, expected);
|
|
51
|
+
else {
|
|
52
|
+
const serializedExpected = printable(expected);
|
|
53
|
+
const serializedActual = printable(actual);
|
|
54
|
+
throw new assert.AssertionError({
|
|
55
|
+
message: `Objects did not have the same constructor:
|
|
56
|
+
Expected: ${serializedExpected}
|
|
57
|
+
Actual: ${serializedActual}`,
|
|
58
|
+
expected: serializedExpected,
|
|
59
|
+
actual: serializedActual
|
|
60
|
+
});
|
|
61
|
+
}
|
|
47
62
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
63
|
+
else if (typeof expected === "object" ||
|
|
64
|
+
typeof expected === "function" ||
|
|
65
|
+
typeof actual === "function" ||
|
|
66
|
+
typeof actual === "function") {
|
|
67
|
+
const serializedExpected = printable(expected);
|
|
68
|
+
const serializedActual = printable(actual);
|
|
69
|
+
throw new assert.AssertionError({
|
|
70
|
+
message: `Assertion including at least one function or object was not between reference eqaul items
|
|
71
|
+
Expected: ${serializedExpected}
|
|
72
|
+
Actual: ${serializedActual}`,
|
|
73
|
+
expected: serializedExpected,
|
|
74
|
+
actual: serializedActual
|
|
75
|
+
});
|
|
76
|
+
// guaranteed to be two primitives at this point
|
|
51
77
|
}
|
|
78
|
+
else
|
|
79
|
+
assert.equal(actual, expected);
|
|
52
80
|
}
|
|
53
|
-
|
|
81
|
+
catch (e) {
|
|
54
82
|
// some nonsense to get a good stack trace
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
e.stack = ctx.assertionStack;
|
|
60
|
-
throw e;
|
|
61
|
-
}
|
|
83
|
+
e.stack = ctx.assertionStack;
|
|
84
|
+
throw e;
|
|
62
85
|
}
|
|
63
86
|
};
|
|
64
87
|
export const assertEquals = versionableAssertion(unversionedAssertEquals);
|
package/out/bench/baseline.js
CHANGED
|
@@ -20,7 +20,7 @@ export const queueBaselineUpdateIfNeeded = (updated, baseline, ctx) => {
|
|
|
20
20
|
snapFunctionName: ctx.lastSnapFunctionName,
|
|
21
21
|
baselinePath: ctx.qualifiedPath
|
|
22
22
|
});
|
|
23
|
-
if (ctx.
|
|
23
|
+
if (ctx.benchCallPosition)
|
|
24
24
|
writeSnapshotUpdatesOnExit();
|
|
25
25
|
};
|
|
26
26
|
/** Pretty print comparison and set the process.exitCode to 1 if delta threshold is exceeded */
|
|
@@ -43,7 +43,13 @@ export const compareToBaseline = (result, ctx) => {
|
|
|
43
43
|
const handlePositiveDelta = (formattedDelta, ctx) => {
|
|
44
44
|
const message = `'${ctx.qualifiedName}' exceeded baseline by ${formattedDelta} (threshold is ${ctx.cfg.benchPercentThreshold}%).`;
|
|
45
45
|
console.error(`📈 ${message}`);
|
|
46
|
-
|
|
46
|
+
const benchErrorConfig = ctx.cfg.benchErrorOnThresholdExceeded;
|
|
47
|
+
const isTypeBench = ctx.lastSnapFunctionName === "instantiations";
|
|
48
|
+
const shouldError = benchErrorConfig === true ||
|
|
49
|
+
(isTypeBench ?
|
|
50
|
+
benchErrorConfig === "types"
|
|
51
|
+
: benchErrorConfig === "runtime");
|
|
52
|
+
if (shouldError) {
|
|
47
53
|
const errorSummary = `❌ ${message}`;
|
|
48
54
|
if (ctx.lastSnapFunctionName === "instantiations")
|
|
49
55
|
throwAssertionError({ stack: ctx.assertionStack, message: errorSummary });
|
package/out/config.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type * as prettier from "prettier";
|
|
|
3
3
|
import type ts from "typescript";
|
|
4
4
|
import { type TsVersionData } from "./tsVersioning.ts";
|
|
5
5
|
export type TsVersionAliases = autocomplete<"*"> | string[];
|
|
6
|
+
export type BenchErrorConfig = "runtime" | "types" | boolean;
|
|
6
7
|
type BaseAttestConfig = {
|
|
7
8
|
tsconfig: string | null | undefined;
|
|
8
9
|
compilerOptions: ts.CompilerOptions;
|
|
@@ -25,7 +26,7 @@ type BaseAttestConfig = {
|
|
|
25
26
|
skipInlineInstantiations: boolean;
|
|
26
27
|
attestAliases: string[];
|
|
27
28
|
benchPercentThreshold: number;
|
|
28
|
-
benchErrorOnThresholdExceeded:
|
|
29
|
+
benchErrorOnThresholdExceeded: BenchErrorConfig;
|
|
29
30
|
filter: string | undefined;
|
|
30
31
|
testDeclarationAliases: string[];
|
|
31
32
|
formatCmd: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ark/attest",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "David Blass",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"@typescript/analyze-trace": "0.10.1",
|
|
37
37
|
"@typescript/vfs": "1.6.0",
|
|
38
38
|
"prettier": "3.4.2",
|
|
39
|
-
"@ark/
|
|
40
|
-
"@ark/
|
|
41
|
-
"arktype": "2.0
|
|
39
|
+
"@ark/util": "0.40.0",
|
|
40
|
+
"@ark/fs": "0.40.0",
|
|
41
|
+
"arktype": "2.1.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"typescript": "5.
|
|
44
|
+
"typescript": "5.8.0-beta"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"typescript": "*"
|