Comfy-Org / Comfy-Org/ComfyUI_frontend
test: add Zod schema validation tests for mock data fixtures to catch drift
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Summary
Mock data fixtures in `browser_tests/fixtures/data/` (e.g., `nodeDefinitions.ts`, `systemStats.ts`) are typed against Zod schemas but are not validated at test time. If `ComfyNodeDef`, `SystemStats`, or any other schema changes, the fixtures can silently drift without any test failure.
## Proposed Fix
Add a Vitest unit test that parses each fixture against its corresponding Zod schema to ensure conformance:
```ts
import { zComfyNodeDef } from '@/schemas/nodeDefSchema'
import { mockNodeDefinitions } from 'browser_tests/fixtures/data/nodeDefinitions'
it('fixtures conform to schema', () => {
Object.values(mockNodeDefinitions).forEach((def) =>
expect(() => zComfyNodeDef.parse(def)).not.toThrow()
)
})
```
Similarly for `mockSystemStats` against the `SystemStats` Zod schema in `src/schemas/apiSchema.ts`.
## Context
- Raised during review of PR #10662 (add mock data fixtures for backend API responses)
- Review comment: https://github.com/Comfy-Org/ComfyUI_frontend/pull/10662#discussion_r3005808060
- Originally suggested by @dante01yoon; deferred out of scope by @christian-byrne for a follow-up PR.
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10707-test-add-Zod-schema-validation-tests-for-mock-data-fixtures-to-catch-drift-3326d73d3650815e82accbd18cd52ece) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.