@shivaedev/effect-test 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0 - 2026-10-16
4
+
5
+ ### Added
6
+
7
+ - `withLive(effect)` from `@shivaedev/effect-test/withLive.ts` runs sleeps and readiness polls in live time under either TestClock or the live clock, without advancing the surrounding TestClock.
8
+
3
9
  ## 0.4.0 - 2026-10-13
4
10
 
5
11
  ### Breaking
package/README.md CHANGED
@@ -160,7 +160,7 @@ Worker acquisition is separate: a Layer that reads the default Clock while it is
160
160
 
161
161
  ### Waiting for a typed readiness condition
162
162
 
163
- `eventually(effect, options)` retries the Effect's typed failures until it succeeds or uses its retry budget. Under TestClock it advances time with `TestClock.adjust`; under live time it retries with `Schedule.spaced`.
163
+ `eventually(effect, options)` retries the Effect's typed failures until it succeeds or uses its retry budget. It uses the active Clock: under TestClock it advances time with `TestClock.adjust`; under live time it retries with `Schedule.spaced`.
164
164
 
165
165
  ```ts
166
166
  import { eventually } from "@shivaedev/effect-test/eventually.ts";
@@ -200,6 +200,19 @@ effectApp("retries a readiness assertion", function* () {
200
200
 
201
201
  This distinction applies under both clocks. The helper preserves the Effect's success, error and service types.
202
202
 
203
+ ### Waiting in live time without advancing TestClock
204
+
205
+ Use `withLive(effect)` from `@shivaedev/effect-test/withLive.ts` for a real-time sleep or readiness poll in a harness, hook or story step. Under TestClock it delegates to native `TestClock.withLive`; under a live clock it runs the Effect directly. The surrounding clock is restored afterward, so waiting for external work does not move virtual token expiry.
206
+
207
+ ```ts
208
+ import { withLive } from "@shivaedev/effect-test/withLive.ts";
209
+
210
+ yield* withLive(Effect.sleep("10 millis"));
211
+ yield* withLive(eventually(queueIsEmpty, { interval: "10 millis", times: 100 }));
212
+ ```
213
+
214
+ The entire wrapped Effect, including readiness checks and retry delays, uses live time. The same call works when a kit defaults to a live clock and one story opts into TestClock. Success, typed failure and service requirements are preserved.
215
+
203
216
  ### API
204
217
 
205
218
  Import the module that defines the name; the package has no root entry.
@@ -209,6 +222,7 @@ Import the module that defines the name; the package has no root entry.
209
222
  | `@shivaedev/effect-test/it.ts` | `it`, with generator-aware `effect` and `live` testers. |
210
223
  | `@shivaedev/effect-test/vitest.ts` | `makeEffectIt({ layer, makeHarness, around?, clock? })`, returning `{ effectApp }`. |
211
224
  | `@shivaedev/effect-test/eventually.ts` | `eventually(effect, options?)` and `EventuallyOptions`. |
225
+ | `@shivaedev/effect-test/withLive.ts` | `withLive(effect)`, a live-time region under either clock. |
212
226
  | `@shivaedev/effect-test/any-test-layer.ts` | `AnyTestLayer` and `buildTestLayer(layer, scope)`, an Effect that builds the Layer's service Context in the supplied scope. |
213
227
  | `@shivaedev/effect-test/types.ts` | `EffectClock`, `EffectTestOptions`, `EffectTestBody`, `EffectTest`, `EffectTester`, `MakeEffectItOptions`, `MakeEffectItResult`, `EffectItTest`, `EffectItTester` and `EffectIt`. |
214
228
 
@@ -0,0 +1,3 @@
1
+ import { type Effect } from "effect";
2
+ export declare function withLive<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>;
3
+ //# sourceMappingURL=withLive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withLive.d.ts","sourceRoot":"","sources":["../src/withLive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAG5C,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAExF"}
@@ -0,0 +1,6 @@
1
+ import { Clock } from "effect";
2
+ import * as TestClock from "effect/testing/TestClock";
3
+ export function withLive(effect) {
4
+ return Clock.clockWith((clock) => ("withLive" in clock ? TestClock.withLive(effect) : effect));
5
+ }
6
+ //# sourceMappingURL=withLive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withLive.js","sourceRoot":"","sources":["../src/withLive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAe,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AAEtD,MAAM,UAAU,QAAQ,CAAU,MAA8B;IAC/D,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,UAAU,IAAI,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAChG,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/effect-test",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Generic Effect Vitest runner with worker-scoped Layers and TestClock",
5
5
  "homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/effect-test#readme",
6
6
  "bugs": {
@@ -43,7 +43,7 @@
43
43
  ],
44
44
  "devDependencies": {
45
45
  "@effect/vitest": "4.0.4",
46
- "@shivaedev/quality": "0.20.0",
46
+ "@shivaedev/quality": "0.21.1",
47
47
  "@types/node": "24.19.1",
48
48
  "@typescript/native": "npm:typescript@7.0.2",
49
49
  "effect": "4.0.4",
@@ -0,0 +1,6 @@
1
+ import { Clock, type Effect } from "effect";
2
+ import * as TestClock from "effect/testing/TestClock";
3
+
4
+ export function withLive<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> {
5
+ return Clock.clockWith((clock) => ("withLive" in clock ? TestClock.withLive(effect) : effect));
6
+ }