Skip to content

Latest commit

 

History

History
269 lines (195 loc) · 7.2 KB

File metadata and controls

269 lines (195 loc) · 7.2 KB

@ark/attest

NOTE: This changelog is incomplete, but will include notable attest-specific changes (many updates consist almost entirely of bumped arktype versions for assertions).

0.47.0

Add a failOnMissingSnapshots config option. Defaults to true if CI is set in your environment, false otherwise.

0.46.0

Fix an issue causing some bench files to not be parsed correctly, leading to errors and 0 instantiation counts.

0.44.3

Decouple attest trace/stats from pnpm

0.44.0

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")

0.41.0

Bail early for obviously incorrect equals comparisons

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)

0.11.0

  • Fix a bug causing certain serialized types with backticks and template literals to be incorrectly formatted on inline snapshot

  • Add a typeToStringFormat option for configuring how prettier stringifies types. Also added more documentation for other pre-existing options.

  • Allow regex/partial match for toString assertions:

// ok
attest({ ark: "type" }).type.toString(/^{.*}$/)

// AssertionError: Actual string 'string[]' did not match regex '^{.*}$'
attest(["ark", "type"]).type.toString(/^{.*}$/)
  • Allow assertions on arbitrary arktype Type instance using satisfies:
// ok
attest({ ark: "type" }).type.toString.satisfies(/^{.*}$/)

// AssertionError: ark must be a number (was string)
attest({ ark: "type" }).satisfies({ ark: "number" })

0.10.0

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.

0.9.4

Improve benchmark source extraction, add notes on baseline expressions

0.9.2

Fix a bug preventing consecutive benchmark runs from populating snapshots inline

0.8.2

Patch Changes

0.8.1

Patch Changes

  • #1024 5284b60 Thanks @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

0.8.0

Minor Changes

  • #1011 2be4f5b Thanks @ssalbdivad! - ### Throw by default when attest.instantiations() exceeds the specified benchPercentThreshold

    Tests 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"])
    })

    Snapshotted completions will now be alphabetized

    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"
    	]
    })

Patch Changes

  • Updated dependencies [2be4f5b]:
    • @ark/util@0.0.49
    • arktype@2.0.0-dev.24

0.7.10

Patch Changes

  • Updated dependencies [232fc42]:
    • @ark/util@0.0.48
    • arktype@2.0.0-dev.20

0.7.9

Patch Changes

  • Updated dependencies [317f012]:
    • @ark/util@0.0.47
    • arktype@2.0.0-dev.19

0.7.8

Patch Changes

  • Updated dependencies [ebe3408]:
    • @ark/util@0.0.46
    • arktype@2.0.0-dev.17

0.7.7

Patch Changes

  • Updated dependencies [79c2b27]:
    • @ark/util@0.0.45
    • arktype@2.0.0-dev.15

0.7.6

Patch Changes

  • 8cd0807 - Initial changeset

  • Updated dependencies [8cd0807]:

    • @ark/fs@0.0.20
    • @ark/util@0.0.44
    • arktype@2.0.0-dev.14