NOTE: This changelog is incomplete, but will include notable attest-specific changes (many updates consist almost entirely of bumped arktype versions for assertions).
Add a failOnMissingSnapshots config option. Defaults to true if CI is set in your environment, false otherwise.
Fix an issue causing some bench files to not be parsed correctly, leading to errors and 0 instantiation counts.
Decouple attest trace/stats from pnpm
Support assertions for JSDoc contents associated with an attested value
const T = type({
/** FOO */
foo: "string"
})
const out = T.assert({ foo: "foo" })
// match or snapshot expected jsdoc associated with the value passed to attest
attest(out.foo).jsdoc.snap("FOO")This is the short-term solution to #1287, where some comparisons with Node's deepStrictEqual and object with recursive properties like Type resulted in OOM crashes.
We will eventually add new string-diffing logic, but for now we just make some shallow comparisons between constructors and types to avoid common problematic comparisons, e.g. between Type instances:
// previously resulted in OOM exception, now shallowly fails with simple error
attest(type.string).equals(type.boolean)-
Fix a bug causing certain serialized types with backticks and template literals to be incorrectly formatted on inline snapshot
-
Add a
typeToStringFormatoption for configuring how prettier stringifies types. Also added more documentation for other pre-existing options. -
Allow regex/partial match for
toStringassertions:
// ok
attest({ ark: "type" }).type.toString(/^{.*}$/)
// AssertionError: Actual string 'string[]' did not match regex '^{.*}$'
attest(["ark", "type"]).type.toString(/^{.*}$/)- Allow assertions on arbitrary
arktypeType instance usingsatisfies:
// ok
attest({ ark: "type" }).type.toString.satisfies(/^{.*}$/)
// AssertionError: ark must be a number (was string)
attest({ ark: "type" }).satisfies({ ark: "number" })Format serialized types using prettier.
This makes long serialized types much more readable:
// old
attest({
ark: "type",
type: "script",
vali: "dator",
opti: "mized",
from: "editor",
to: "runtime"
}).type.toString.snap(
`{ ark: string; type: string; vali: string; opti: string; from: string; to: string; }`
)
// new
attest({
ark: "type",
type: "script",
vali: "dator",
opti: "mized",
from: "editor",
to: "runtime"
}).type.toString.snap(`{
ark: string
type: string
vali: string
opti: string
from: string
to: string
}`)Be aware, this is likely means you will need to regenerate existing type snaps to avoid failing due to formatting inconsistencies.
You should be able to update all your snapshots by running your tests with the --updateSnapshots flag or setting ATTEST_updateSnapshots=1 in your environment.
If you have any non-snap type.toString assertions, you will need to update them manually. You may want to convert them temporarily to snaps so you can easily see the correct value.
Improve benchmark source extraction, add notes on baseline expressions
Fix a bug preventing consecutive benchmark runs from populating snapshots inline
-
#1028
5fe79c6Thanks @ssalbdivad! - Bump version -
Updated dependencies [
5fe79c6]:- @ark/util@0.0.51
- arktype@2.0.0-dev.26
-
#1024
5284b60Thanks @ssalbdivad! - ### Add .satisfies as an attest assertion to compare the value to an ArkType definition.attest({ foo: "bar" }).satisfies({ foo: "string" }) // Error: foo must be a number (was string) attest({ foo: "bar" }).satisfies({ foo: "number" })
-
Updated dependencies [
1bf2066]:- @ark/util@0.0.50
- arktype@2.0.0-dev.25
-
#1011
2be4f5bThanks @ssalbdivad! - ### Throw by default when attest.instantiations() exceeds the specified benchPercentThresholdTests like this will now correctly throw inline instead of return a non-zero exit code:
it("can snap instantiations", () => { type Z = makeComplexType<"asbsdfsaodisfhsda"> // will throw here as the actual number of instantiations is more // than 20% higher than the snapshotted value attest.instantiations([1, "instantiations"]) })
This will help improve stability, especially for large completion lists like this one which we updated more times than we'd care to admit 😅
attest(() => type([""])).completions({ "": [ "...", "===", "Array", "Date", "Error", "Function", "Map", "Promise", "Record", "RegExp", "Set", "WeakMap", "WeakSet", "alpha", "alphanumeric", "any", "bigint", "boolean", "creditCard", "digits", "email", "false", "format", "instanceof", "integer", "ip", "keyof", "lowercase", "never", "null", "number", "object", "parse", "semver", "string", "symbol", "this", "true", "undefined", "unknown", "uppercase", "url", "uuid", "void" ] })
- Updated dependencies [
2be4f5b]:- @ark/util@0.0.49
- arktype@2.0.0-dev.24
- Updated dependencies [
232fc42]:- @ark/util@0.0.48
- arktype@2.0.0-dev.20
- Updated dependencies [
317f012]:- @ark/util@0.0.47
- arktype@2.0.0-dev.19
- Updated dependencies [
ebe3408]:- @ark/util@0.0.46
- arktype@2.0.0-dev.17
- Updated dependencies [
79c2b27]:- @ark/util@0.0.45
- arktype@2.0.0-dev.15