Counter

Overview

A basic counter demonstrates how Fault Sense validates state changes through user interactions. Each button click is monitored to ensure the counter display updates correctly with the expected value, using both exact text matching and regex patterns.

Implementation

<!-- Counter Display -->
<div id="counter">Count: ${count}</div>

<!-- Counter Controls -->
<button fs-feature="Counter"
        fs-assert="IncrementCounter"
        fs-trigger="click"
        fs-assert-updated="#counter"
        fs-assert-text-matches="Count: ${count + 1}">
  Increment
</button>

<button fs-feature="Counter"
        fs-assert="DecrementCounter"
        fs-trigger="click"
        fs-assert-updated="#counter"
        fs-assert-text-matches="Count: -?[0-9]+">
  Decrement
</button>

Try it

Count: 0

Key Attributes

fs-feature

Groups counter assertions under the 'Counter' feature for organized reporting

fs-assert

Unique identifiers for each counter action (IncrementCounter, DecrementCounter)

fs-trigger

Event that triggers the assertion (click for both buttons)

fs-assert-updated

Validates that the counter display element is updated after the action

fs-assert-text-matches

Validates the counter text matches expected value (dynamic template for increment, regex for decrement)

Demo Event Collector

Note: Demo Mode

The Fault Sense events shown here are real assertions that have been resolved as you played with the interactive demos.

In production, events will be sent to a backend event collection endpoint that you configure, allowing results to be aggregated across all users.

No Fault Sense events detected yet.

Interact with the examples to see events logged here.