Back to docs

Test Coverage Map

Added in v6.5.0

Visualize which pages on your site are covered by tests and identify gaps that need attention.

Quick Start

# Generate full coverage report
cbrowser coverage "https://example.com" --tests "tests/*.txt"

# Generate HTML report
cbrowser coverage "https://example.com" --tests "tests/*.txt" --html --output report.html

# Quick view of untested pages only
cbrowser coverage gaps "https://example.com" --tests "tests/*.txt"

How It Works

  1. Parse Test Files - Extracts URLs visited and actions performed (clicks, fills, verifications)
  2. Discover Site Pages - Crawls your site or parses sitemap.xml
  3. Match Coverage - Compares tested pages against all discovered pages
  4. Identify Gaps - Flags untested or under-tested pages by priority
  5. Generate Report - Produces actionable coverage report

Commands

Full Coverage Analysis

cbrowser coverage <url> [options]

Options:
  --tests <glob>        Test files to analyze (default: tests/*.txt)
  --sitemap <url>       Use sitemap.xml instead of crawling
  --max-pages <n>       Max pages to crawl (default: 100)
  --include <pattern>   Only include paths matching pattern
  --exclude <pattern>   Exclude paths matching pattern
  --min-coverage <n>    Min coverage % to not flag (default: 50)
  --html                Generate HTML report
  --output <file>       Save report to file

Quick Gap Analysis

cbrowser coverage gaps <url> [options]

Options:
  --tests <glob>        Test files to analyze
  --sitemap <url>       Use sitemap.xml

Coverage Score Calculation

Each tested page gets a coverage score (0-100%) based on:

Action Type Points
Navigate (visit page) 20
Click interactions +25
Form fills +25
Verifications/assertions +30

A page with navigation + clicks + fills + verifications = 100% coverage.

Gap Priorities

Pages are prioritized for testing based on their path:

Priority Path Patterns Examples
Critical checkout, payment, login, register, signup, auth /checkout/payment, /auth/login
High account, profile, settings, dashboard, admin /account/settings, /admin/users
Medium Pages with forms or 10+ interactive elements /contact, /apply
Low Other pages /about, /faq

Example Output

Text Report

╔══════════════════════════════════════════════════════════════════════════════╗
β•‘                         TEST COVERAGE MAP REPORT                            β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

πŸ“Š Site: https://example.com
πŸ“… Generated: 2026-02-02T10:30:00.000Z
⏱️  Analysis time: 45.2s
πŸ“ Test files analyzed: 12

═══════════════════════════════════════════════════════════════════════════════
πŸ“ˆ OVERALL COVERAGE
═══════════════════════════════════════════════════════════════════════════════

  Coverage: β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 32%

  Total pages:    50
  Tested pages:   16
  Untested pages: 34

───────────────────────────────────────────────────────────────────────────────
πŸ“ COVERAGE BY SECTION
───────────────────────────────────────────────────────────────────────────────

  βœ… /products             β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 8/10 (80%)
  ⚠️ /account              β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 4/10 (40%)
  ❌ /checkout             β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 0/5 (0%)
  ❌ /admin                β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 0/8 (0%)

═══════════════════════════════════════════════════════════════════════════════
πŸ•³οΈ  COVERAGE GAPS
═══════════════════════════════════════════════════════════════════════════════

  🚨 /checkout/payment
     Reason: untested | Priority: critical
     Suggested: go to https://example.com/checkout/payment

  🚨 /checkout/confirmation
     Reason: untested | Priority: critical
     Suggested: go to https://example.com/checkout/confirmation

  πŸ”΄ /account/settings
     Reason: untested | Priority: high
     Suggested: go to https://example.com/account/settings

HTML Report

The HTML report provides an interactive visualization with:

  • Overall coverage donut chart
  • Section-by-section breakdown
  • Clickable gap list sorted by priority
  • Tested pages grid with coverage scores

CI/CD Integration

Fail Build on Low Coverage

# Exit code 1 if coverage below 50%
cbrowser coverage "https://staging.example.com" --tests "tests/*.txt" --min-coverage 50

# Stricter threshold for production
cbrowser coverage "https://example.com" --tests "tests/*.txt" --min-coverage 70

GitHub Actions Example

- name: Test Coverage Check
  run: |
    npx cbrowser coverage "${{ env.PREVIEW_URL }}" \
      --tests "tests/*.txt" \
      --min-coverage 50 \
      --html \
      --output coverage-report.html

- name: Upload Coverage Report
  uses: actions/upload-artifact@v3
  with:
    name: coverage-report
    path: coverage-report.html

Test File Format

CBrowser parses natural language test files to extract coverage:

# Test: Login Flow
go to https://example.com/login
type "[email protected]" in email field
type "password123" in password field
click the login button
verify url contains "/dashboard"

# Test: Product Search
go to https://example.com/products
type "widget" in search box
click search button
verify page contains "results"
click on first product
verify page contains "Add to Cart"

Recognized patterns:

  • go to, navigate to, open, visit β†’ Navigation
  • click, click on, click the β†’ Click action
  • type, fill, enter β†’ Fill action
  • verify, assert, check, expect, should β†’ Verification
  • wait, wait for β†’ Wait action

Best Practices

  1. Test Critical Paths First - Checkout, authentication, and payment flows
  2. Add Verifications - Don't just navigate, verify content and behavior
  3. Use Sitemap for Large Sites - Faster than crawling
  4. Set Realistic Thresholds - Start at 50%, increase over time
  5. Review Gaps Regularly - Make coverage improvement part of sprint planning

Programmatic API

import {
  generateCoverageMap,
  formatCoverageReport,
  generateCoverageHtmlReport
} from 'cbrowser';

const result = await generateCoverageMap(
  'https://example.com',
  ['tests/login.txt', 'tests/checkout.txt'],
  {
    maxPages: 100,
    minCoverage: 50
  }
);

console.log(`Coverage: ${result.analysis.coveragePercent}%`);
console.log(`Gaps: ${result.gaps.length}`);

// Generate reports
const textReport = formatCoverageReport(result);
const htmlReport = generateCoverageHtmlReport(result);

Related


Copyright: (c) 2026 Alexa Eden.

License: MIT License

Contact: [email protected]

From the Blog