Files
portal/tools/enforce-verify-record.test.mjs
T
Дмитрий f44de52e08 fix(hooks): extractTestMetrics — recognise Vitest "passed | N skipped" formats
Pre-fix all three regexes in extractTestMetrics fell through when Vitest
output contained " | N skipped" between "passed" and "(TOTAL)" — so any
test suite with .skip()'ed tests produced sentinel result=fail (false
negative), blocking subsequent git commit.

Two new patterns:
- "Tests  N passed | M skipped (TOTAL)"
- "Tests  X failed | N passed | M skipped (TOTAL)"

Companion tests in tools/enforce-verify-record.test.mjs (new file matches
TDD-gate basename heuristic) and tools/enforce-verify-before-push.test.mjs.

Verified RED to GREEN: 38/38 tests pass after fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 19:25:44 +03:00

19 lines
839 B
JavaScript

import { describe, it, expect } from 'vitest';
import { extractTestMetrics } from './enforce-verify-record.mjs';
describe('enforce-verify-record / extractTestMetrics — Vitest skipped formats', () => {
it('parses vitest passed-only with skipped', () => {
// Vitest 4.x summary when some tests are .skip()'ed:
// "Tests 924 passed | 3 skipped (927)"
// Pre-fix all three regexes fell through → result=fail (false negative).
expect(extractTestMetrics('Tests 924 passed | 3 skipped (927)')).toMatchObject({
tests_passed: 924, tests_failed: 0, tests_total: 927,
});
});
it('parses vitest failed+passed+skipped triplet', () => {
expect(extractTestMetrics('Tests 1 failed | 920 passed | 3 skipped (924)')).toMatchObject({
tests_failed: 1, tests_passed: 920, tests_total: 924,
});
});
});