This tests the pattern validation functionality.
npm run test:validatorThis runs a comprehensive test suite that covers:
- Pattern validation (valid/invalid patterns)
- Pattern file validation
- Error, warning, and suggestion detection
- Integration tests with sample pattern files
Test with valid patterns:
npm run validate -- --pattern test-patterns-valid.ymlTest with invalid patterns:
npm run validate -- --pattern test-patterns-invalid.ymlvalidator.test.ts- Main unit test file with simple testing frameworktest-patterns-valid.yml- Sample file with valid patterns for integration testingtest-patterns-invalid.yml- Sample file with invalid patterns for testing error detection
The tests use a simple, lightweight testing framework built into the test file that provides:
- Basic assertions (
assertEquals,assertTrue,assertFalse,assertContains) - Test organization and reporting
- Colored output for easy reading
- Error handling and reporting
To add new tests, add them to the runTests() function in validator.test.ts:
test.test('your test name', () => {
// Your test logic here
test.assertTrue(someCondition);
test.assertEquals(actualValue, expectedValue);
});For async tests, use:
await test.testAsync('async test name', async () => {
// Your async test logic here
});