Skip to main content

Overview

World Monitor includes three test suites:
  1. E2E Tests — Playwright tests for full user flows across variants
  2. API Tests — Node.js tests for serverless functions and handlers
  3. Visual Regression — Screenshot comparison for map layers

E2E Tests (Playwright)

Run All Tests

Run the complete E2E suite across all variants:
This command runs:
  1. Runtime fetch tests (variant-agnostic API checks)
  2. Full variant tests
  3. Tech variant tests
  4. Finance variant tests

Run Tests by Variant

Test Configuration

Test Files

Example Test: Runtime Fetch

Run Specific Test

The -g flag matches test names via regex.

Debug Mode

Opens Playwright Inspector for step-by-step debugging.

Headed Mode

Runs tests in a visible browser window.

Visual Regression Tests

Golden Screenshot Tests

Map layer rendering is validated using golden screenshots:

Run Visual Tests

Update Golden Screenshots

When map rendering changes intentionally:
This regenerates baseline screenshots in e2e/map-harness.spec.ts-snapshots/.
Only update golden screenshots when you’ve intentionally changed map rendering. Accidental updates will mask regressions.

API Tests (Node.js)

Run API Tests

This command runs Node.js tests using the --test flag:

Test Files

Data Validation Tests

Runs tests in tests/ using tsx --test:

RSS Feed Validation

Validates all RSS feed URLs are reachable:

Regression Testing

Map Overlay Behavior

From the README:
Map overlay behavior is validated in Playwright using the map harness (/tests/map-harness.html).
  • Cluster-state cache initialization guard:
    • updates protest marker click payload after data refresh
    • initializes cluster movement cache on first protest cluster render
  • Run by variant:
    • npm run test:e2e:full -- -g "updates protest marker click payload after data refresh|initializes cluster movement cache on first protest cluster render"
    • npm run test:e2e:tech -- -g "updates protest marker click payload after data refresh|initializes cluster movement cache on first protest cluster render"
These tests ensure:
  1. Cluster cache initialization — Supercluster state is cached on first render
  2. Click payload accuracy — Marker click handlers receive up-to-date data after refresh

Run Regression Tests

Continuous Integration

GitHub Actions

Test Coverage

Covered Areas

  • API endpoint responses (20+ services)
  • Map layer rendering (40+ layers)
  • Circuit breaker persistence
  • Keyword spike detection
  • Theme switching (dark/light)
  • Mobile map interactions
  • Investment panel (Finance variant)
  • CORS policy
  • RSS feed parsing
  • GeoJSON data validation

Not Covered

  • WebSocket connections (AIS relay)
  • Desktop OS keychain integration
  • Ollama/LM Studio auto-discovery
  • Service worker updates
  • IndexedDB snapshot storage
These areas require manual testing or platform-specific test environments.

Best Practices

Write tests for bug fixes. When you fix a bug, add a test that would have caught it.
Use test:e2e:runtime for API changes. This test runs fast and validates all API endpoints.
Don’t update golden screenshots blindly. Review visual diffs carefully before running --update-snapshots.
Tests run serially (workers: 1) to avoid race conditions in shared state (service worker, localStorage).

Debugging Failed Tests

View Trace Files

Playwright saves traces for failed tests in test-results/.

View Screenshots

Failed tests save screenshots to test-results/:

View Video Recordings

Videos are saved for failed tests when video: 'retain-on-failure' is set:

Next Steps

Deployment

Deploy to production

Contributing

Contribute to World Monitor