@@ -21,14 +21,15 @@ All files | 81.81 | 66.66 | 80 | 88.88 |
2121
2222** Legend**
2323- ** 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)
2526- ** Functions** = Subschemas
2627
2728## Limitations
2829
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.
3032
31- - Coverage can only be reported for ` *.schema.(json|yaml|yml) ` files.
3233- Keywords can pass/fail for multiple reasons, but not all branches are captured
3334 - Example: ` type: ["object", "boolean"] ` . If you test with an object and a
3435 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.
3839
3940Integration with vitest is provided. You'll need a vitest config specifically
4041for 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"] ` .
4254
4355` vitest-schema.config.js `
44- ``` JavaScript
56+ ``` TypeScript
4557import { defineConfig } from " vitest/config" ;
58+ import type { JsonSchemaCoverageProviderOptions } from " @hyperjump/json-schema-coverage/vitest-coverage-provider" ;
4659
4760export default defineConfig ({
4861 test: {
4962 coverage: {
5063 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
5367 }
5468});
5569```
0 commit comments