Commit Graph

2 Commits

Author SHA1 Message Date
c02dcb0ad4 fix: Update validator.ts TypeScript type annotations for Ajv compatibility 2026-01-21 03:12:56 +00:00
8b32a877cc feat: Add comprehensive test migration tooling
Add AST-based migration framework for converting TypeScript tests to JSON:

New files:
- scripts/migrate-tests/converter.ts (350+ lines)
  * AST parser for .test.ts files
  * Extracts describe/it/expect blocks
  * Maps 30+ Jest/Vitest matchers to JSON types
  * Returns structured ConversionResult

- scripts/migrate-tests/migrator.ts (250+ lines)
  * Batch discovery and migration orchestrator
  * Glob-based .test.ts file discovery
  * Automatic output directory creation
  * Dry-run mode for safe preview
  * Pretty-printed progress reporting
  * Package name mapping (frontends → packages)

- scripts/migrate-tests/validator.ts (300+ lines)
  * JSON schema validation using AJV
  * Semantic checks (unique IDs, assertions)
  * Unused import warnings
  * Directory-wide validation support
  * Structured ValidationResult output

- scripts/migrate-tests/index.ts
  * Unified export module

- scripts/migrate-tests/README.md
  * Comprehensive usage guide
  * Conversion process documentation
  * Matcher mapping reference
  * Workflow recommendations
  * Troubleshooting guide

Features:
* 80/20 conversion (handles ~80% of tests cleanly)
* Fallback for complex tests requiring manual adjustment
* Dry-run mode to preview changes
* Verbose logging for troubleshooting
* Validates against tests_schema.json

Matcher Support:
* Basic: equals, deepEquals, notEquals, truthy, falsy
* Numeric: greaterThan, lessThan, greaterThanOrEqual, lessThanOrEqual
* Type: null, notNull, undefined, notUndefined, instanceOf
* Collection: contains, matches, hasProperty, hasLength
* DOM: toBeVisible, toBeInTheDocument, toHaveTextContent, toHaveAttribute, toHaveClass, toBeDisabled, toBeEnabled, toHaveValue
* Control: throws, notThrows, custom

This completes Phase 3 Task 4 of the JSON interpreter everywhere implementation.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-21 03:06:27 +00:00