Skip to content

Add comprehensive test suites for all analyzer plugins#48

Merged
YusukeHirao merged 3 commits intomainfrom
claude/test-analyze-plugin-eEXK1
Mar 5, 2026
Merged

Add comprehensive test suites for all analyzer plugins#48
YusukeHirao merged 3 commits intomainfrom
claude/test-analyze-plugin-eEXK1

Conversation

@YusukeHirao
Copy link
Copy Markdown
Member

@YusukeHirao YusukeHirao commented Mar 5, 2026

Summary

This PR adds complete test coverage for all five analyzer plugins in the @nitpicker package. Each plugin now has a dedicated test suite covering core functionality, edge cases, and error handling.

closes: #12

Key Changes

Test Files Added

  • analyze-axe: 334 lines of tests covering accessibility violations, locale configuration, rule disabling, and error handling
  • analyze-textlint: 313 lines of tests for text linting with severity mapping, rule merging, and linter reuse
  • analyze-main-contents: 295 lines of tests for main content detection with word counting, heading/image/table extraction, and selector fallbacks
  • analyze-search: 277 lines of tests for keyword and selector searching with scoping and attribute filtering
  • analyze-markuplint: 233 lines of tests for HTML markup validation with URL normalization and violation mapping

Test Coverage Highlights

  • Mocking: All external dependencies (axe-core, textlint, markuplint, jsdom) are properly mocked
  • Edge Cases: Null/missing values, invalid selectors, whitespace handling, and error conditions
  • Configuration: Custom options, locale loading, rule merging, and selector overrides
  • Data Transformation: Proper mapping of violations/messages to standardized format with severity levels and location info
  • Integration: Multi-page processing, lazy initialization, and state management across calls

Notable Implementation Details

  • Uses Vitest with dynamic module imports to support lazy plugin initialization
  • JSDOM integration for DOM-based tests (main-contents, search plugins)
  • Comprehensive mocking of axe-core locale imports with fallback testing
  • Tests verify both successful paths and graceful error handling

https://claude.ai/code/session_01ERi5hKHKWmJAfdkkxUGMbb

claude added 3 commits March 5, 2026 10:26
Add index.spec.ts for analyze-axe, analyze-main-contents,
analyze-markuplint, analyze-search, and analyze-textlint.
External dependencies are mocked; DOM-dependent plugins use JSDOM.

https://claude.ai/code/session_01ERi5hKHKWmJAfdkkxUGMbb
- analyze-axe: verify axe.configure with locale success/failure, assert
  color-contrast rule disabled in axe.run()
- analyze-search: use hardcoded literals instead of expect.any(Number),
  prove scope restricts matches to 1, add attribute match and excluded
  attribute tests
- analyze-markuplint: use toHaveBeenLastCalledWith to avoid stale mock
  history
- analyze-textlint: verify TextlintKernelDescriptor receives merged
  rules with disabled rules excluded and overridden options
- analyze-main-contents: add #content/.main fallback selector tests
  and DOM-order priority test

https://claude.ai/code/session_01ERi5hKHKWmJAfdkkxUGMbb
Add TODO comment documenting the Content object key inconsistency
between toHeader (uses item.search) and toArray (uses item.title).
This causes report header keys to not match result keys when using
Content objects. The test records this current (buggy) behavior.

https://claude.ai/code/session_01ERi5hKHKWmJAfdkkxUGMbb
@YusukeHirao YusukeHirao merged commit 326f633 into main Mar 5, 2026
3 checks passed
@YusukeHirao YusukeHirao deleted the claude/test-analyze-plugin-eEXK1 branch March 5, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

テストカバレッジ: analyze プラグイン 6 パッケージが完全未テスト

2 participants