@@ -82,6 +82,77 @@ These can be used with:
8282pnpm build
8383```
8484
85+ ### Testing
86+
87+ This package includes comprehensive test coverage for all Zod schemas using ** Vitest** .
88+
89+ ``` bash
90+ # Run tests once
91+ pnpm test
92+
93+ # Run tests in watch mode
94+ pnpm test:watch
95+
96+ # Run tests with coverage report
97+ pnpm test:coverage
98+ ```
99+
100+ #### Test Structure
101+
102+ Tests are co-located with schema files using the ` .test.ts ` suffix:
103+
104+ ``` text
105+ src/
106+ ├── data/
107+ │ ├── field.zod.ts # Schema definition
108+ │ ├── field.test.ts # Tests
109+ │ ├── object.zod.ts
110+ │ └── object.test.ts
111+ ├── ui/
112+ │ ├── view.zod.ts
113+ │ └── view.test.ts
114+ └── system/
115+ ├── manifest.zod.ts
116+ └── manifest.test.ts
117+ ```
118+
119+ #### Test Coverage
120+
121+ Each test file includes:
122+ * ** Schema Validation Tests** : Verify valid inputs pass and invalid inputs fail
123+ * ** Default Value Tests** : Ensure default values are applied correctly
124+ * ** Type Tests** : Test discriminated unions and type narrowing
125+ * ** Constraint Tests** : Validate naming conventions (snake_case), regex patterns, enums
126+ * ** Real-World Examples** : Complete, realistic examples from CRM, HR, Sales domains
127+
128+ ** Current Coverage** : 263 tests across 13 test files with 100% coverage for tested schemas.
129+
130+ #### Writing Tests
131+
132+ When adding new schemas, follow these patterns:
133+
134+ ``` typescript
135+ import { describe , it , expect } from ' vitest' ;
136+ import { YourSchema } from ' ./your-schema.zod' ;
137+
138+ describe (' YourSchema' , () => {
139+ it (' should accept valid data' , () => {
140+ const valid = { /* valid data */ };
141+ expect (() => YourSchema .parse (valid )).not .toThrow ();
142+ });
143+
144+ it (' should reject invalid data' , () => {
145+ const invalid = { /* invalid data */ };
146+ expect (() => YourSchema .parse (invalid )).toThrow ();
147+ });
148+
149+ it (' should apply defaults' , () => {
150+ const result = YourSchema .parse ({ /* minimal data */ });
151+ expect (result .someField ).toBe (' default-value' );
152+ });
153+ });
154+ ```
155+
85156### Directory Structure
86157
87158``` text
@@ -91,5 +162,6 @@ packages/spec/
91162│ ├── ui/ # ObjectUI Protocol
92163│ └── system/ # ObjectOS Protocol
93164├── json-schema/ # Auto-generated (npm run gen:schema)
94- └── dist/ # Compiled JS/D.TS
165+ ├── dist/ # Compiled JS/D.TS
166+ └── vitest.config.ts # Test configuration
95167```
0 commit comments