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
- Parse Test Files - Extracts URLs visited and actions performed (clicks, fills, verifications)
- Discover Site Pages - Crawls your site or parses sitemap.xml
- Match Coverage - Compares tested pages against all discovered pages
- Identify Gaps - Flags untested or under-tested pages by priority
- 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β Navigationclick,click on,click theβ Click actiontype,fill,enterβ Fill actionverify,assert,check,expect,shouldβ Verificationwait,wait forβ Wait action
Best Practices
- Test Critical Paths First - Checkout, authentication, and payment flows
- Add Verifications - Don't just navigate, verify content and behavior
- Use Sitemap for Large Sites - Faster than crawling
- Set Realistic Thresholds - Start at 50%, increase over time
- 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
- Natural-Language-Tests - Write the tests that get analyzed
- Flaky-Test-Detection - Ensure test reliability
- CLI-Reference - Full command documentation
Copyright: (c) 2026 Alexa Eden.
License: MIT License
Contact: [email protected]