Skip to content

motus-v1.0.8

Choose a tag to compare

@github-actions github-actions released this 10 Apr 21:45
· 92 commits to main since this release

Performance testing, browser health detection, and reliability improvements across the test execution pipeline.

New Features

  • Performance metrics collection - Built-in Core Web Vitals collection via CDP Performance domain and PerformanceObserver API. Collects LCP, FCP, TTFB, CLS, INP, JS heap size, DOM node count, and individual layout shift entries. Metrics are gathered automatically after each navigation when the performance hook is enabled.
  • Performance budget assertions - New page-level assertions ToMeetPerformanceBudgetAsync(), ToHaveLcpBelowAsync(), ToHaveFcpBelowAsync(), ToHaveTtfbBelowAsync(), ToHaveClsBelowAsync(), and ToHaveInpBelowAsync() with auto-retry semantics and .Not negation support.
  • [PerformanceBudget] attribute - Apply to test methods or classes to declare metric thresholds. Budgets resolve from method attribute, class attribute, motus.config.json, or MOTUS_PERFORMANCE_* environment variables. Test framework adapters (MSTest, NUnit, xUnit) resolve the attribute and propagate it to the page automatically.
  • Performance CLI support - motus run --perf-budget enables budget enforcement from the command line. All built-in reporters (Console, HTML, JUnit, TRX) surface collected metrics and budget pass/fail status.
  • Browser health detection - Background BrowserHeartbeat pings Chrome every 5 seconds with a 10-second timeout to detect frozen browsers. Process.Exited event provides instant crash detection. Both mechanisms are guarded against double-firing and trigger the Disconnected event for downstream recovery.
  • IBrowser.IsHealthy property - Default interface member that checks both connection state and process liveness. For launched browsers, returns false when the process has exited even if the WebSocket has not yet detected the disconnect.
  • BrowserFixture auto-restart - When Chrome crashes or becomes unresponsive, BrowserFixture automatically disposes the dead browser and launches a replacement with retry. A SemaphoreSlim gate coordinates restart so NewContextAsync callers block briefly rather than racing against a dead browser. Compatible with parallel test execution across all three frameworks.
  • BrowserPool proactive replenishment - The browser pool subscribes to each browser's Disconnected event. On crash, the dead browser is disposed, its capacity slot is released, and a replacement is launched if the pool has dropped below MinInstances.

Improvements

  • Performance reporter integration - Reporters implementing IPerformanceReporter receive metrics alongside budget evaluation results. The visual runner surfaces metrics in timeline marker tooltips and a dedicated Performance section in the step detail panel.
  • Test method name propagation - TestMethodNameContext (AsyncLocal) carries the test method name from the visual runner's TestExecutionService into test base classes, enabling [PerformanceBudget] attribute resolution when the framework's TestContext is not injected.

Bug Fixes

  • CI test suite slowdown - Performance assertion tests blocked for 60 seconds per test because RefreshPerformanceMetricsAsync sent CDP commands with CancellationToken.None and no mock response was queued. Fixed by forwarding the assertion retry helper's cancellation token through to the CDP send, and queueing proper Runtime.evaluate responses in all affected tests. Reduced Motus.Tests.dll runtime from 16 minutes back to 2 minutes.
  • BrowserHeartbeat double-dispose - CloseAsync followed by DisposeAsync on a browser threw ObjectDisposedException because the heartbeat's CancellationTokenSource was disposed twice. Fixed with an Interlocked.CompareExchange guard on the heartbeat's DisposeAsync.
  • Tracing race condition - PumpTracingCompleteAsync used a shared _completeTcs field, allowing a cancelled old pump's cancellation handler to poison the next run's TaskCompletionSource. Fixed by passing a local TCS as a parameter.
  • CancellationTokenSource leaks - WaitForRequestAsync and WaitForResponseAsync in NetworkManager created linked CTS instances that were never disposed. Fixed with ContinueWith disposal on the returned task.
  • ScreencastService circular dependency - OnPageClose called StopAsync() which awaited operations that depended on the page being open. Simplified to cancel the pump and unsubscribe the event handler directly.