Skip to content

Dependency Audit

The Dependency Audit is the core analysis engine of the Architecture module. It scans your test codebase for structural weaknesses and quantifies them with actionable metrics.

Page Object Coverage

The audit calculates what percentage of your application's pages and components are abstracted behind Page Object classes:

text
Page Object Coverage: 72%
  ├── With PO:     18 pages (login, dashboard, cart, ...)
  ├── Without PO:   7 pages (settings, profile, admin/*, ...)
  └── Inline only:  3 pages (tests use raw selectors, no abstraction)

Tests without Page Objects are harder to maintain — a single UI change can break dozens of tests.

Target Coverage

Aim for at least 85% Page Object coverage. The remaining 15% can be simple utility pages or one-off tests where abstraction adds no value.

Selector Quality

The audit flags fragile selectors that are likely to break on minor DOM changes:

Selector PatternRisk LevelRecommendation
.container > div:nth-child(3)CriticalUse getByRole or getByTestId
#auto-generated-id-7f3aCriticalReplace with stable data-testid
.btn.primary.largeWarningPrefer getByRole('button', { name })
[data-testid="submit-btn"]SafeStable, explicit test identifier
getByRole('button', { name: 'Submit' })SafeSemantic, resilient to DOM changes
text
Selector Quality Score: 64/100
  Critical selectors: 12 (in 8 files)
  Warning selectors:  23 (in 14 files)
  Safe selectors:     89 (in 31 files)

nth-child Selectors

nth-child selectors are the most common cause of flaky tests. A single new element in the DOM shifts all indices, breaking every test that relies on positional selection.

Code Duplication

The audit detects repeated code patterns across your test files:

  • Duplicated setup blocks — identical beforeEach logic in multiple files
  • Repeated selector strings — the same CSS selector hardcoded in several places
  • Copy-pasted assertion chains — identical assertion sequences that should be helper functions

Each duplicate cluster is shown with the affected files and a suggested extraction target (helper function, fixture, or Page Object method).

Structural Metrics

A summary table of project-level metrics:

MetricValueBenchmark
Total test files47
Average test length34 lines< 50 lines recommended
Fixture usage ratio61%> 70% recommended
Max import depth4 levels< 5 recommended
Orphan helpers3 files0 is ideal

Orphan Helpers

Orphan helpers are utility files that exist in the test directory but are not imported by any test. They may be dead code or missing integrations.

Running the Audit

  1. Open Architecture > Dependency Audit
  2. Click Start Scan — the analysis typically completes in 5-15 seconds
  3. Review the results organized by category (Coverage, Selectors, Duplication, Metrics)
  4. Click any finding to see affected files and generate an AI fix

Local-first QA orchestration.