@@ -21,14 +21,15 @@ All files | 81.81 | 66.66 | 80 | 88.88 |
21
21
22
22
** Legend**
23
23
- ** Statements** = Keywords and subschemas
24
- - ** Branches** = true/false branches for each keyword
24
+ - ** Branches** = true/false branches for each keyword (except for keywords that
25
+ don't branch such as annotation-only keywords)
25
26
- ** Functions** = Subschemas
26
27
27
28
## Limitations
28
29
29
- The following are known limitations I'm hopeful can be addressed.
30
+ The following are a list of known limitations. Some might be able to be
31
+ addressed at some point, while others might not.
30
32
31
- - Coverage can only be reported for ` *.schema.(json|yaml|yml) ` files.
32
33
- Keywords can pass/fail for multiple reasons, but not all branches are captured
33
34
- Example: ` type: ["object", "boolean"] ` . If you test with an object and a
34
35
number, you've covered pass/fail, but haven't tested that a boolean should
@@ -38,18 +39,31 @@ The following are known limitations I'm hopeful can be addressed.
38
39
39
40
Integration with vitest is provided. You'll need a vitest config specifically
40
41
for running schema coverage. You can't run with coverage for both your js/ts
41
- code and schema at the same time.
42
+ code and schema code at the same time.
43
+
44
+ By default, it will track coverage for any file with a ` *.schema.json ` ,
45
+ ` *.schema.yaml ` , or ` *.schema.yml ` extension. You can change this with the
46
+ ` include ` option.
47
+
48
+ ** Options**
49
+
50
+ - ** include** -- An array of glob paths of schemas you want to track coverage
51
+ for. For example, if you keep your schemas in a folder called ` schemas ` and
52
+ they just have plain extensions (` *.json ` ) instead of schema extensions
53
+ ` *.schema.json ` , you could use ` ["./schemas/**/*.json"] ` .
42
54
43
55
` vitest-schema.config.js `
44
- ``` JavaScript
56
+ ``` TypeScript
45
57
import { defineConfig } from " vitest/config" ;
58
+ import type { JsonSchemaCoverageProviderOptions } from " @hyperjump/json-schema-coverage/vitest-coverage-provider" ;
46
59
47
60
export default defineConfig ({
48
61
test: {
49
62
coverage: {
50
63
provider: " custom" ,
51
- customProviderModule: " @hyperjump/json-schema-coverage/vitest-coverage-provider"
52
- }
64
+ customProviderModule: " @hyperjump/json-schema-coverage/vitest-coverage-provider" ,
65
+ include: [" ./schemas/**/*.json" ] // Optional
66
+ } as JsonSchemaCoverageProviderOptions
53
67
}
54
68
});
55
69
```
0 commit comments