Skip to content

check object shorthand: deep should default to true #154

Description

@DmitrySharabin

Problem

The default check function (equals) is deep — it's defined as deep(shallowEquals()). But when using the object shorthand to customize check behavior, deep previously defaulted to false (no default was set in the destructuring). This creates a usability cliff: the moment a user customizes check via object shorthand, they silently lose deep comparison unless they explicitly add deep: true.

Example

// Default check — deep comparison, works on nested objects
{
    run: () => ({ a: { b: 1 } }),
    expect: { a: { b: 1 } },
    // ✅ passes — default equals is deep
}

// Object shorthand — loses deep comparison
{
    run: () => ({ a: { b: 1 } }),
    expect: { a: { b: 1 } },
    check: { subset: true },
    // ❌ fails — shallowEquals can't compare objects by structure
}

// Must explicitly opt in
{
    run: () => ({ a: { b: 1 } }),
    expect: { a: { b: 1 } },
    check: { subset: true, deep: true },
    // ✅ passes
}

Docs mismatch

docs/define/README.md states deep defaults to false. PR #153 changed the code to default to true, which matches user expectations (consistent with the default equals check) but contradicts the docs.

Proposed fix

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions