@arktype/attest
Advanced tools
Comparing version 0.7.3 to 0.7.5
@@ -1,2 +0,2 @@ | ||
import { snapshot, type Constructor, type Guardable } from "@arktype/util"; | ||
import { snapshot, type Constructor } from "@arktype/util"; | ||
import type { Completions } from "../cache/writeAssertionCache.js"; | ||
@@ -13,6 +13,5 @@ import type { AssertionContext } from "./attest.js"; | ||
private serialize; | ||
private get actual(); | ||
private get unversionedActual(); | ||
private get serializedActual(); | ||
private snapRequiresUpdate; | ||
narrow(predicate: Guardable, messageOnError?: string): never; | ||
get unknown(): this; | ||
@@ -54,3 +53,2 @@ is(expected: unknown): this; | ||
completions: (value?: Completions) => void; | ||
narrow<narrowed>(predicate: (data: unknown) => data is narrowed, messageOnError?: string): narrowed; | ||
unknown: Omit<comparableValueAssertion<unknown, kind>, "unknown">; | ||
@@ -57,0 +55,0 @@ }; |
@@ -16,3 +16,3 @@ import { caller } from "@arktype/fs"; | ||
} | ||
get actual() { | ||
get unversionedActual() { | ||
if (this.ctx.actual instanceof TypeAssertionMapping) { | ||
@@ -24,3 +24,3 @@ return this.ctx.actual.fn(this.ctx.typeRelationshipAssertionEntries[0][1], this.ctx).actual; | ||
get serializedActual() { | ||
return this.serialize(this.actual); | ||
return this.serialize(this.unversionedActual); | ||
} | ||
@@ -31,14 +31,4 @@ snapRequiresUpdate(expectedSerialized) { | ||
// to the snap even though it will serialize to the same value as the (nonexistent) first arg | ||
this.actual === undefined); | ||
this.unversionedActual === undefined); | ||
} | ||
narrow(predicate, messageOnError) { | ||
if (!predicate(this.actual)) { | ||
throwAssertionError({ | ||
ctx: this.ctx, | ||
message: messageOnError ?? | ||
`${this.serializedActual} failed to satisfy predicate${predicate.name ? ` ${predicate.name}` : ""}` | ||
}); | ||
} | ||
return this.actual; | ||
} | ||
get unknown() { | ||
@@ -48,15 +38,15 @@ return this; | ||
is(expected) { | ||
assert.equal(this.actual, expected); | ||
assert.equal(this.unversionedActual, expected); | ||
return this; | ||
} | ||
equals(expected) { | ||
assertEquals(expected, this.actual, this.ctx); | ||
assertEquals(expected, this.ctx.actual, this.ctx); | ||
return this; | ||
} | ||
instanceOf(expected) { | ||
if (!(this.actual instanceof expected)) { | ||
if (!(this.ctx.actual instanceof expected)) { | ||
throwAssertionError({ | ||
ctx: this.ctx, | ||
message: `Expected an instance of ${expected.name} (was ${typeof this.actual === "object" && this.actual !== null ? | ||
this.actual.constructor.name | ||
message: `Expected an instance of ${expected.name} (was ${typeof this.ctx.actual === "object" && this.ctx.actual !== null ? | ||
this.ctx.actual.constructor.name | ||
: this.serializedActual})` | ||
@@ -87,3 +77,3 @@ }); | ||
// but serialize to the same value. | ||
if (printable(args[0]) !== printable(this.actual)) | ||
if (printable(args[0]) !== printable(this.unversionedActual)) | ||
assertEquals(expectedSerialized, this.serializedActual, this.ctx); | ||
@@ -124,5 +114,5 @@ } | ||
if (this.ctx.allowRegex) | ||
assertEqualOrMatching(expected, this.actual, this.ctx); | ||
assertEqualOrMatching(expected, this.ctx.actual, this.ctx); | ||
else | ||
assertEquals(expected, this.actual, this.ctx); | ||
assertEquals(expected, this.ctx.actual, this.ctx); | ||
return this; | ||
@@ -135,3 +125,3 @@ }; | ||
get throws() { | ||
const result = callAssertedFunction(this.actual); | ||
const result = callAssertedFunction(this.unversionedActual); | ||
this.ctx.actual = getThrownMessage(result, this.ctx); | ||
@@ -143,3 +133,3 @@ this.ctx.allowRegex = true; | ||
throwsAndHasTypeError(matchValue) { | ||
assertEqualOrMatching(matchValue, getThrownMessage(callAssertedFunction(this.actual), this.ctx), this.ctx); | ||
assertEqualOrMatching(matchValue, getThrownMessage(callAssertedFunction(this.unversionedActual), this.ctx), this.ctx); | ||
if (!this.ctx.cfg.skipTypes) { | ||
@@ -146,0 +136,0 @@ assertEqualOrMatching(matchValue, new TypeAssertionMapping(data => ({ |
@@ -19,3 +19,3 @@ import { shell, writeJson } from "@arktype/fs"; | ||
else { | ||
forTypeScriptVersions(config.tsVersions, version => shell(`npm exec -c "attestPrecache ${join(config.assertionCacheDir, version.alias + ".json")}"`)); | ||
forTypeScriptVersions(config.tsVersions, version => shell(`npm exec -c "attest precache ${join(config.assertionCacheDir, version.alias + ".json")}"`)); | ||
} | ||
@@ -22,0 +22,0 @@ }; |
{ | ||
"name": "@arktype/attest", | ||
"version": "0.7.3", | ||
"version": "0.7.5", | ||
"author": { | ||
@@ -33,5 +33,5 @@ "name": "David Blass", | ||
"dependencies": { | ||
"arktype": "2.0.0-dev.10", | ||
"@arktype/fs": "0.0.18", | ||
"@arktype/util": "0.0.37", | ||
"arktype": "2.0.0-dev.11", | ||
"@arktype/fs": "0.0.19", | ||
"@arktype/util": "0.0.41", | ||
"@typescript/vfs": "1.5.0", | ||
@@ -38,0 +38,0 @@ "@typescript/analyze-trace": "0.10.1" |
@@ -158,2 +158,8 @@ # Attest | ||
If you'd like to fail in CI above a threshold, you can add flags like the following (default value is 20%, but it will not throw unless `--benchErrorOnThresholdExceeded` is set): | ||
``` | ||
tsx ./p99/within-limit/p99-tall-simple.bench.ts --benchErrorOnThresholdExceeded --benchPercentThreshold 10 | ||
``` | ||
## CLI | ||
@@ -160,0 +166,0 @@ |
272
131041
4203
+ Added@arktype/fs@0.0.19(transitive)
+ Added@arktype/schema@0.1.2(transitive)
+ Added@arktype/util@0.0.380.0.41(transitive)
+ Addedarktype@2.0.0-dev.11(transitive)
- Removed@arktype/fs@0.0.18(transitive)
- Removed@arktype/schema@0.1.1(transitive)
- Removed@arktype/util@0.0.360.0.37(transitive)
- Removedarktype@2.0.0-dev.10(transitive)
Updated@arktype/fs@0.0.19
Updated@arktype/util@0.0.41
Updatedarktype@2.0.0-dev.11