@ark/attest 0.45.6 → 0.45.8
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/LICENSE +1 -1
- package/README.md +9 -6
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright 2025 ArkType
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
|
@@ -20,6 +20,9 @@ _Note: This package is still in alpha! Your feedback will help us iterate toward
|
|
|
20
20
|
|
|
21
21
|
To use attest's type assertions, you'll need to call our setup/cleanup methods before your first test and after your last test, respectively. This usually involves some kind of globalSetup/globalTeardown config.
|
|
22
22
|
|
|
23
|
+
> [!IMPORTANT]
|
|
24
|
+
> If you run your tests in watch mode or otherwise iteratively during dev, you will want to enable [`--skipTypes` mode](#skiptypes).
|
|
25
|
+
|
|
23
26
|
### Vitest
|
|
24
27
|
|
|
25
28
|
`vitest.config.ts`
|
|
@@ -76,7 +79,7 @@ Here are some simple examples of type assertions and snapshotting:
|
|
|
76
79
|
// @ark/attest assertions can be made from any unit test framework with a global setup/teardown
|
|
77
80
|
describe("attest features", () => {
|
|
78
81
|
it("type and value assertions", () => {
|
|
79
|
-
const
|
|
82
|
+
const Even = type("number%2")
|
|
80
83
|
// asserts even.infer is exactly number
|
|
81
84
|
attest<number>(even.infer)
|
|
82
85
|
// make assertions about types and values seamlessly
|
|
@@ -114,18 +117,18 @@ describe("attest features", () => {
|
|
|
114
117
|
|
|
115
118
|
it("jsdoc snapshotting", () => {
|
|
116
119
|
// match or snapshot expected jsdoc associated with the value passed to attest
|
|
117
|
-
const
|
|
120
|
+
const T = type({
|
|
118
121
|
/** FOO */
|
|
119
122
|
foo: "string"
|
|
120
123
|
})
|
|
121
124
|
|
|
122
|
-
const out =
|
|
125
|
+
const out = T.assert({ foo: "foo" })
|
|
123
126
|
|
|
124
127
|
attest(out.foo).jsdoc.snap("FOO")
|
|
125
128
|
})
|
|
126
129
|
|
|
127
130
|
it("integrate runtime logic with type assertions", () => {
|
|
128
|
-
const
|
|
131
|
+
const ArrayOf = type("<t>", "t[]")
|
|
129
132
|
const numericArray = arrayOf("number | bigint")
|
|
130
133
|
// flexibly combine runtime logic with type assertions to customize your
|
|
131
134
|
// tests beyond what is possible from pure static-analysis based type testing tools
|
|
@@ -136,7 +139,7 @@ describe("attest features", () => {
|
|
|
136
139
|
})
|
|
137
140
|
|
|
138
141
|
it("integrated type performance benchmarking", () => {
|
|
139
|
-
const
|
|
142
|
+
const User = type({
|
|
140
143
|
kind: "'admin'",
|
|
141
144
|
"powers?": "string[]"
|
|
142
145
|
})
|
|
@@ -197,7 +200,7 @@ export const getDefaultAttestConfig = (): BaseAttestConfig => ({
|
|
|
197
200
|
|
|
198
201
|
`skipTypes` is extremely useful for iterating quickly during development without having to typecheck your project to test runtime logic.
|
|
199
202
|
|
|
200
|
-
When this setting is enabled, setup will skip
|
|
203
|
+
When this setting is enabled, setup will skip type checking and all assertions requiring type information will be skipped.
|
|
201
204
|
|
|
202
205
|
You likely want two scripts, one for running tests with types and one for tests without:
|
|
203
206
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ark/attest",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "David Blass",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"@typescript/analyze-trace": "0.10.1",
|
|
37
37
|
"@typescript/vfs": "1.6.1",
|
|
38
38
|
"prettier": "3.5.3",
|
|
39
|
-
"@ark/
|
|
40
|
-
"@ark/
|
|
41
|
-
"arktype": "2.1.
|
|
39
|
+
"@ark/fs": "0.45.8",
|
|
40
|
+
"@ark/util": "0.45.8",
|
|
41
|
+
"arktype": "2.1.18"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"typescript": "5.8.2"
|