Skip to content

@effect/vitest@4.0.0-rc.113

Pre-release
Pre-release

Choose a tag to compare

@effect-bot effect-bot released this 10 Sep 00:39
d3b837a

Patch Changes

  • #7254 a63dcbf Thanks @gcanti! - Add the experimental Schema-first effect/unstable/arbitrary/Arbitrary module for native generation without
    fast-check. Arbitrary.schema derives an opaque arbitrary from the decoded Schema Type, Arbitrary.sampleEffect
    provides interruptible sampling with typed exhaustion, and Arbitrary.checkEffect returns structured property results.
    The initial implementation supports bounded discards, shrinking, replay, and recursive and mutually recursive Schemas.
    SampleError and Exhausted include the effective seed so discarded runs remain reproducible even when the caller did
    not provide one. Arbitrary.isArbitrary identifies values through the module's nominal protocol. Numeric constraints
    retain NaN when it is accepted by their supported Order.Number bounds. Union derivation validates oneOf
    exclusivity and isolates lazy cross-member shrinking from unrelated random generation. Object derivation keeps
    optional-property selection constructive when candidate fields have different recursive costs.
    Struct, Record, JSON-object, and record-shaped Arbitrary.all outputs periodically use a null prototype as an edge
    case, preserving that prototype throughout shrinking and replay without perturbing structural PRNG choices. The change
    adds 0.01–0.03 KB gzip to representative Arbitrary fixtures and leaves production-only bundle sentinels unchanged.

    Add Arbitrary.map, Arbitrary.flatMap, Arbitrary.filter, Arbitrary.filterMap, and Arbitrary.all for composing
    derived Arbitraries without exposing a second catalog of primitive constructors. Filtering remains bounded and
    promotes valid shrink descendants through rejected nodes. maxShrinks bounds every inspected shrink candidate,
    including candidates rejected before property evaluation, while retaining the best shrunk input found when the
    budget is exhausted. flatMap provides deterministic dependent generation, source-first shrinking, post-source PRNG
    checkpoints, and one shared residual recursion budget. all combines tuples, iterables, and records with a shared
    budget, randomized internal generation order, stable output shape, and independent member shrinking. Arbitrary values
    implement Pipeable for composition with data-last combinators.

    Add the experimental Schema arbitraryConstraint and toCodecArbitrary annotations and their
    Schema.Annotations.ToArbitrary types. Declarations can provide a Schema Link optimized for generation, while filters
    can contribute native semantic constraints. The callback receives decoded type parameters and normalized constraints.
    The compiler owns efficient representations for common built-ins, including JSON, RegExp, URL, Date, byte arrays,
    ReadonlyMap, and ReadonlySet. Effect-specific HashMap, HashSet, Chunk, Graph, BigDecimal, and date-time declarations keep
    local generation Links, while declarations with productive canonical codecs require no arbitrary-specific annotation.
    Schema.isUniqueKey provides key-based Map uniqueness for explicit array representations.

    The same ownership policy applies to formatter and equivalence derivation: implementations for common declarations
    live in their compiler, while domain-specific and dynamically constructed declarations retain local annotations.
    Declarations whose intrinsic Equal implementation already matches their Schema equivalence need no annotation or
    compiler special case. This keeps unused common callbacks out of production Schema bundles.

    Against the previous layout, schema-toArbitrary decreases from 36.68 KB to 33.24 KB gzip and
    arbitrary-combinators decreases from 37.16 KB to 33.70 KB. schema-toFormatter increases from 18.92 KB to 19.49 KB
    and schema-toEquivalence increases from 19.05 KB to 19.39 KB because callers that explicitly derive these capabilities
    now retain the common declaration handlers. Generic production fixtures remain unchanged; an equivalence-specific
    production fixture using common declarations decreases from 20.75 KB to 20.48 KB, while declarations whose intrinsic
    equality is sufficient decrease from 23.42 KB to 23.34 KB. An Arbitrary-specific production fixture using common
    declarations decreases from 20.35 KB to 19.61 KB, while one using the locally annotated BigDecimal and date-time
    declarations increases from 18.34 KB to 23.01 KB.
    The complete 31-scenario native Arbitrary comparison reports no statistically classified runtime regression; the five
    moved BigDecimal and date-time scenarios remain within measurement noise.

    Add SchemaGetter.forbiddenEncoding, a reusable getter for the encode side of decode-only Schema transformations.

    Remove the fast-check bridge from the effect package, including Schema.toArbitrary and
    effect/testing/FastCheck. Replace the legacy Schema.Annotations.ToArbitrary callback contract with the native
    Schema-first types. The effect package no longer depends on fast-check.

    Migrate TestSchema.Asserts.verifyLosslessTransformation and TestSchema.Asserts.arbitrary().verifyGeneration to the
    native runner. Both methods now accept native check options directly, bound unsuccessful generation, and include the
    shrunk input and replay token in property failures.

    Use the Arbitrary runner for all @effect/vitest property tests. Property inputs may combine Schemas and Arbitraries,
    and are composed directly with Arbitrary.all; check options are available through arbitrary. Raw fast-check
    arbitraries and the fastCheck options object are no longer supported. As with the previous fast-check adapter, thrown
    exceptions, defects, and typed failures from a property are shrinkable falsifications; Effect interruption remains an
    interruption.

    Optimize constructive regular-expression generation by caching feasible lengths on the compiled pattern, computing
    sequence-suffix feasibility once, and precomputing character-class metadata. Seeded generation, shrinking, and replay
    remain unchanged.

    Optimize BigDecimal.Order and BigDecimal.Equivalence with a shared hybrid comparator. Ordinary scale differences
    use cached, bounded coefficient alignment, while large differences are compared without materializing their decimal
    zeroes. BigDecimal.make now rejects scales that are not safe integers.

    Before its removal, the materialized fast-check bridge fixture
    schema-toArbitrary-materialized-fast-check.ts measured 79.00 KB minified and gzipped.

    Representative runtime measurements against corresponding hand-written fast-check 4.9.0 arbitraries are shown below.
    Values are median latency on Node 24.12.0 and Apple M3; lower is better. Both implementations validate the
    same output domains, although their generation distributions are not identical. Native speedup is fast-check latency
    divided by Native latency, so higher is better.

    Scenario fast-check Native Native speedup
    32 recursive samples 150 µs 103 µs 1.45x
    128 optional Struct samples 244 µs 86.0 µs 2.84x
    128 constrained strings 742 µs 49.7 µs 14.86x
    RegExp derivation and first sample 13.4 ms 30.8 µs 429.02x
    64 RegExp strings 595 µs 919 µs 0.64x
    RegExp failure and shrinking 168 µs 88.2 µs 1.91x
    128 bounded numbers 68.9 µs 21.8 µs 3.18x
    128 Uint8Array samples 98.3 µs 74.4 µs 1.32x
    128 BigDecimal samples 66.6 µs 56.3 µs 1.18x
    128 DateTime.Utc samples 71.2 µs 50.5 µs 1.42x
    128 named time zones 52.2 µs 27.9 µs 1.85x
    128 time zones 63.7 µs 33.8 µs 1.89x
    128 zoned date-times 130 µs 112 µs 1.16x
    32 samples through Schema filter 65.9 µs 49.4 µs 1.33x
    32 unique arrays 156 µs 132 µs 1.18x
    128 literal samples 40.0 µs 3.70 µs 10.78x
    128 mapped samples 59.0 µs 14.1 µs 4.21x
    128 samples through passing filter 58.9 µs 13.9 µs 4.23x
    32 samples through selective filter 66.1 µs 42.9 µs 1.54x
    128 filterMap samples 75.7 µs 31.5 µs 2.40x
    Filtered failure and shrinking 12.7 µs 7.71 µs 1.66x
    128 all tuple samples 43.5 µs 18.5 µs 2.35x
    128 all record samples 81.0 µs 30.4 µs 2.66x
    128 dependent flatMap samples 125 µs 67.2 µs 1.86x
    flatMap failure and shrinking 20.1 µs 6.71 µs 2.99x
    Replay flatMap shrink path 14.3 µs 6.57 µs 2.17x
    Passing property, 100 runs 42.3 µs 27.1 µs 1.56x
    TestSchema, 100 generations 44.5 µs 35.9 µs 1.24x
    First failure plus one shrink 8.77 µs 1.30 µs 6.75x
    Replay recorded failure 6.35 µs 1.19 µs 5.36x

    Cold recursive derivation is not included because the native fixture constructs and compiles a Schema, while the
    fast-check fixture constructs a hand-written arbitrary; it is not a like-for-like warm-generator comparison.

    Add a guide for the native module and a migration guide from the fast-check bridge published in effect@4.0.0-rc.109.

  • #8154 3993340 Thanks @tim-smart! - Await asynchronous test and layer finalizers after an Effect test times out before starting the next test.

  • #8104 e9915d5 Thanks @tim-smart! - Require Vitest >=5.0.0 <6.0.0 and Node.js ^22.12.0 || ^24.0.0 || >=26.0.0.

    Breaking changes

    • Replace .sequential and { sequential: true } with { concurrent: false }.
    • Use bench from the test context and await bench(name, fn).run(). The top-level benchmark API is removed.
    • Use Assertion<void, T> or Assertion<Promise<void>, T>. Define custom matchers through vitest.Matchers, not @vitest/expect.
    • Import reporter types from vitest/node and environment/snapshot APIs from vitest/runtime. Set outputFile when consuming JSON reports.
    • Await asynchronous assertions. Mock history now clears before each test.

    See the Vitest migration guide for removed types and other upstream changes.

  • #8104 e9915d5 Thanks @tim-smart! - Add a concurrent option to named layer and it.layer suites. Omitted options and anonymous layers preserve inherited concurrency.

  • Updated dependencies [49e3901, b945ded, d6422f4, 5a80204, 53511ef, 79ae49f, 0d083ba, be0f822, debe8fd, a8588f9, f17eb0a, f30cbfe, 78cc9c0, ccbdbd5, a63dcbf, b845b18, 381b794, 4ffcaf4, ba2fd82, 02be94c, 115d8c2, 1452635, 77f85fe, a3f2b31, 310f8d3, 291d616, 48dbbb2, b43bfd6, 1c89c78, 9bbe1a5, dd99ab0, 8f397ed, d7ae6b6, 8cf1203, 87654c5, f05ae0b, 436f5eb, d8ff960, 8766475, b64f406, 4697aaa, cec6c2d, 9956f0e, 5c7eed0, 183c2ea, 1e92dbd, 4eb0fa7, 534b8b9, b76a1cf, acc1e53, 4950a91, c020987, abe95d1, 027ceb9, 3d203b7, a29b8f4, ce4aa65, a8ea807, a3ebb7f, 473bd81, 53843f6, c5eca65, d6f9eba, 8d1e97a, b28ab48, 9960708, 8ac53b6, 84ad49a, 72cfa24, 95c2581, d5c7cd2, fe4fed1, d150a64, 05b1e80, 414dc90, 3f51acd, d68ff05, f3cf1e6, 6525771, 4ab4e83, f7f1d78, 47b358a, 45ffa72, 6232650, 4b73e1b, 284050c, c85fc0b, 7999b07, 7d455f5, d681c2e, 84d2a47, ed74b18, 2245997, d386979, fc9fedf, 7750dbe, fc91af6, 39b9738, 88093b5, d14c463, d473bd3, 84864bc, e2ae724, f921ed3, 1df933d, 829aff9, aa0aba3, a71140f, 0276a27, 10d2c98, c86c999, 975f758, 2a3a478, 1e6e206, fa6027b, 7616f73, fc668b6, d425c8c, ce120f4, 248201f, e80d397, f1a941d, 73bc3a1, b628bb1, 6e3ae7b, e891247, 53e6c73, 1579d6f, d3c6b73, 4a59c6a, 145d8e1, f74282c, 0a38623, 0a08ae0, fa6a56b, d60c5d4, 07ffd25, 9b517ad, 604b1c1, ccc2e02, 14d810a, a9d1ee3, a31adbe, 7245f87, 3a0828b, cd83544, 6550a07, 6f090d4, b505c0d, 186dd49, 9f37e58, 4446451, 58be972, 1320075, ba53b64, f7490d4, c8ea602, 62d82f4, a2c9e7c, 97dd022, f984ee8, f1b2910, a29e05a, 1aa1d8b, bb99734, 222e7ca, 797c9e3, b4d5398, c8349ed, 8426e5f, 26e0085, 1a86166, 0856631, 0af0985, bc582c9, 2c63f1e, 0d98213, ca6f0dc, d8cc9ed, 42fd969, 5641ad3, 629870d, d592c14, 10d2c98, 53909a9, 78a4269, 06c6307, 0847c41, 5a77084, 96f99b3, 7bb8781, 4907e9b, 2a30248, 8364ddd, ad67d8c, ec0c087, fa6a56b, a2c1ce6, 91e9af0, 7bd3f34, ef16581, 1693a87, df3fc47, e11be41, 2e39e8b, 11c5ee7, 1742d2f, 8efc70e, 9642776, 6680828, c34edcb, 7b2c5bd, 1a2ccee, db995df, af0ccdd, addeaea, 7704034, e72b12f, 310dd9c, 1c2afc1, 44f44ca, f43b9d6, 56e72b3, 50ef80e, fc3b718, ee336d8, d12f922, 46d8310, 59812fd, f9d0dec, 4372c79, 81485ef, bd393d6, 0c95c04]:

    • effect@4.0.0-rc.113