Property-based testing

An example test checks one input you picked. A property test states a rule that must hold for every input. It generates many inputs and shrinks a failing input to a small counterexample.

Effect 4 ships its own engine in effect/Arbitrary. Arbitrary.schema derives a generator from an Effect Schema. The same schema defines the capability’s contract21 and generates its test inputs. Arbitrary.checkEffect checks a pure or effectful property and “shrinks the first falsification.” Arbitrary.ts

@effect/vitest exposes it as it.prop and it.effect.prop.

The capture-first7 events cartridge36 is tested this way. For any generated request:

A property earns its place only if breaking the code breaks it. When first written, the events tests did not fail when token was removed from the sensitive-key list. The property compared the filter with the same function it was testing.

A second property with an independent list of sensitive keys closed the gap. The failure shrank to a single input, "secret": "token". See tests that earn their place22.

For sequences of actions, use model-based testing14.

See also: Tests through supplied services22.

Sources

  1. Effect contributors. 2026. Arbitrary. Effect 4.0.0.. GitHub Effect-TS/effect. Arbitrary API; used for generated inputs and shrinking failures. Accessed 2026-10-01.
  2. rat-stack/packages/events/test at main · joelhooks/rat-stack · GitHub. GitHub joelhooks/rat-stack. Events properties; used for capture invariants over generated requests. Accessed 2026-10-01.
  3. David K 🎹 on X: "@joelhooks I need to get you on the MBT/PBT train" / X. David Khourshid. Public reply; used for David's invitation to adopt property-based testing. Accessed 2026-10-01.

Last changed 2026-10-07 in f1a00f2. Source on GitHub. Change log.

Linked from

  1. Accumulate independent errors before writing output. Check every independent job before any job writes an asset.

    See property-based testing and the glossary.¶

  2. Agent guide. An Effect stack so pure (aspirational) Kit Langton will blush.

    Property-based testing — State a rule that must hold for every input, then let a generator hunt for the smallest input that breaks it.

  3. Agents explore, tests remember. Let agent users explore scenarios; turn a good bug reproduction into a repeatable test.

    Property-based testing shrinks a failure to a small counterexample.

  4. Analytics. One event per HTTP request, stored unchanged for queries to select and interpret later.

    The cartridge uses property-based testing and model-based testing.¶

  5. Capture first, shape later. Store events without rejecting them for an evolving event shape, then decide their shape when you query.

    Property tests check these rules.

  6. Change log. What changed in the files served here, newest first.

    Property-based testing — edited: feat(learn): teach cards 63 to 82 with plain lines, diagrams and snippets

  7. Code snippets quote a pinned source. Shipped design brief: pinned Git objects, typed diagnostics, and one build-only snippet model for both views.

    The package ships property tests for these rules.

  8. David Khourshid. David Khourshid teaches state machines with XState and argues for model-based and property-based testing.
    Link context

    On 2026-10-01 he told Joel, “I need to get you on the MBT/ PBT train.” X MBT means model-based testing: compare the application with a model across action sequences.

  9. Full agent guide. An Effect stack so pure (aspirational) Kit Langton will blush.
  10. Learn mode presents concepts at useful depths. An agent presents source-derived concepts during real work and keeps learning events in a private local log.

    Property tests check depth and merge.

  11. Model-based testing. Describe what a system should do as a small model, generate action sequences, and check the real system against the model.

    See property-based testing for single-input rules.¶

  12. Rat Stack lore | rat-stack. Short, source-grounded notes on the ideas and decisions behind rat-stack.

    Property-based testing — State a rule that must hold for every input, then let a generator hunt for the smallest input that breaks it.

  13. Schemas define the boundary. Define accepted data with Schema, decode unknown input before dispatch, and encode results through the declared contract.

    Property tests still need an independent rule that those values must satisfy.¶

  14. Source change history (log.md). The generated change log as Markdown.

    Property-based testing — edited: feat(learn): teach cards 63 to 82 with plain lines, diagrams and snippets

  15. test-behaviour. Pick the test shape that proves a behaviour. Use when you ask "how do I test this?", add a test, test a domain rule, a lifecycle, a retry, a session, a UI interaction, a timer, or a race, or review a test that might be tautological.

    Read property-based testing.¶

  16. Tests prove behavior through supplied services. Supply services through Layers, choose properties or models for domain rules, and reject tests that cannot detect broken behavior.

    Property-based testing records that planted violation and the smaller counterexample.¶

  17. Tokenize the whole file before slicing. Select lines after tokenization so preceding code still guides recognition of multiline strings and comments.

    See property-based testing.¶

  18. uncomplect. Find responsibilities that a rat-stack design combines, separate them into capabilities, cartridges, machines, features, and clients, and enforce that separation through types and checks. Use when asked to simplify, review, or replace a design, "what would Rich Hickey do", "optimize for deletion", or "define this error out of existence".

    A property test checks a rule across generated inputs.