feat: CLI scanner — static test quality analysis AB#434#1
Merged
Conversation
npx @iklab/testkit scan ./tests — analyzes test files for: - Flaky code patterns (setTimeout, fetch, Date.now, Math.random, process.env, fs I/O) - Missing assertions (test bodies without expect/assert) - Conditional assertions (expect inside if/else) - Focused tests (.only) and skipped tests (.skip, x-prefix) - Duplicate test names across files (Jaccard similarity) - Flaky descriptions (reuses existing flaky() function) Architecture: AST-based using acorn + @sveltejs/acorn-typescript. Two-tier analysis: structure extraction + code body scanning. Text output with ANSI colors + --json flag for CI. Exit codes: 0 clean, 1 issues found, 2 fatal error. 24 new tests (scanner.test.ts), 150 total passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1. process.env: changed isMemberCall to isMemberAccess — was checking for process.env() (CallExpression) instead of process.env.X (MemberExpression). Pattern never triggered before this fix. 2. Symlink cycle protection: walkDir now tracks visited real paths via realpathSync() + Set. Max depth 50 prevents stack overflow. 3. File size limit: CLI skips files > 5MB to prevent OOM on huge generated files. 4. New test: process.env detection in flaky fixture. 151 tests passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
9 new tests: - globToRegex: wildcard, question mark, dot escaping, exact match - text-reporter: header, clean report, summary stats - json-reporter: valid JSON, all sections present Also exported globToRegex for testing. 160 total tests passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
npx @iklab/testkit scan ./tests— static test quality scannerWhat it detects
CLI options
--json— JSON output for CI integration--threshold <1-10>— min flakiness score to report--no-duplicates— skip duplicate detection--no-code-analysis— descriptions only--pattern <glob>— custom file patternTest plan
AB#434
🤖 Generated with Claude Code