This document provides a summary of the comprehensive test suite created for the Price Hider browser extension.
- Total Tests: 107
- Test Files: 2
- All Tests Passing: ✅ Yes
------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------|---------|----------|---------|---------|-------------------
All files | 98.42 | 84.94 | 100 | 98.4 |
content.js | 98.42 | 84.94 | 100 | 98.4 | 304,340
------------|---------|----------|---------|---------|-------------------
- Statement Coverage: 98.42% ✅ (Target: 70%)
- Branch Coverage: 84.94% ✅ (Target: 70%)
- Function Coverage: 100% ✅ (Target: 70%)
- Line Coverage: 98.4% ✅ (Target: 70%)
Unit tests covering individual functions and logic:
- ✅ Dollar amounts with prefix ($100)
- ✅ Dollar amounts with suffix (100€)
- ✅ Various currency codes (USD, EUR, GBP, etc.)
- ✅ Avoiding false positives (plain numbers)
- ✅ Detection with currency symbols
- ✅ Detection with currency codes
- ✅ Rejection without currency
- ✅ Rejection without digits
- ✅ Empty/null handling
- ✅ Preventing duplicate style injection
- ✅ CSS rule validation
- ✅ Simple price text masking
- ✅ Multiple prices in same text
- ✅ Script tag exclusion
- ✅ Input field exclusion
- ✅ Ignore attribute respect
- ✅ Split-element price identification
- ✅ Already processed element rejection
- ✅ Broad container tag rejection
- ✅ Non-price content rejection
- ✅ Long text rejection
- ✅ Ignored section handling
- ✅ Script tag text nodes
- ✅ Style tag text nodes
- ✅ Input element text nodes
- ✅ Already masked text nodes
- ✅ Ignored section text nodes
- ✅ Regular text nodes
- ✅ Orphaned text nodes
- ✅ Schema.org attributes
- ✅ ARIA labels
- ✅ Multiple currencies
- ✅ Number format variations
- ✅ Price ranges
- ✅ Content preservation
- ✅ Empty elements
- ✅ Deeply nested structures
- ✅ Text boundary prices
- ✅ Special characters
- ✅ Excessive spacing
- ✅ Malformed HTML
- ✅ Whitespace-only text
- ✅ Dollar ($)
- ✅ Euro (€)
- ✅ Pound (£)
- ✅ Yen (¥)
- ✅ Rupee (₹)
- ✅ Won (₩)
- ✅ Ruble (₽)
- ✅ Baht (฿)
- ✅ Large element counts (100+ items)
- ✅ Rapid DOM changes
End-to-end integration tests using actual exported functions:
- injectStyles (3 tests)
- looksLikePrice (3 tests)
- isPriceContainer (7 tests)
- shouldSkipTextNode (8 tests)
- hasPriceMatch (2 tests)
- maskTextNode (6 tests)
- maskPriceElements (6 tests)
- walkAndMask - Full Integration (9 tests)
- ✅ E-commerce product listings
- ✅ Shopping carts
- ✅ International pricing
- ✅ Discount labels
- ✅ Malformed prices
- ✅ Very long numbers
- ✅ Text boundaries
- ✅ Empty documents
- ✅ Deep nesting
- ✅ Mixed content
- ✅ Unicode/special characters
- Test Framework: Jest 29.7.0
- Test Environment: jsdom (simulated browser environment)
- DOM Testing Utilities: @testing-library/dom 10.4.0
Tests verify detection and masking of:
- 30+ currency symbols
- 14+ currency codes
- Various number formats (commas, periods, spaces)
- Text-based price masking
- Element-level price containers
- Split-element prices (currency and amount in separate elements)
- Schema.org microdata
- Accessibility attributes
- Script/style tag exclusion
- Input field protection
- Selective ignoring via data attributes
- Non-destructive masking
- Handles 100+ price elements
- Rapid DOM mutation handling
- Deep nesting support
# Install dependencies
npm install
# Run all tests
npm test
# Run tests in watch mode (for development)
npm run test:watch
# Generate coverage report
npm run test:coverageThese tests are ready to be integrated into CI/CD pipelines:
# Example GitHub Actions workflow
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
- name: Check coverage
run: npm run test:coverageWhen adding new features to the extension:
- Add unit tests in
content.test.jsfor new functions - Add integration tests in
content.integration.test.jsfor workflows - Ensure coverage remains above 70% (current: 98%+)
- Test both happy paths and edge cases
- Run tests before committing:
npm test
- All tests run in an isolated jsdom environment
- No actual browser required for testing
- Tests are fast (completes in <1 second)
- Zero test flakiness - deterministic results
- Cross-platform compatible (macOS, Linux, Windows)