@logixjs/test 0.0.2 → 1.0.1

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.
Files changed (39) hide show
  1. package/dist/Act.cjs +2 -2
  2. package/dist/Act.js +1 -1
  3. package/dist/{Assertions-uDVCBadW.d.cts → Assertions-CzVzJ0dQ.d.cts} +1 -1
  4. package/dist/{Assertions-OpNAhiI_.d.ts → Assertions-D2zfasOD.d.ts} +1 -1
  5. package/dist/Assertions.cjs +3 -2
  6. package/dist/Assertions.d.cts +3 -2
  7. package/dist/Assertions.d.ts +3 -2
  8. package/dist/Assertions.js +2 -2
  9. package/dist/{TestProgram-BLXiWhJQ.d.cts → TestProgram-BNm-06UK.d.cts} +4 -3
  10. package/dist/{TestProgram-CPvVAbfI.d.cts → TestProgram-DHhYdhOm.d.cts} +1 -1
  11. package/dist/{TestProgram-X35n_2Js.d.ts → TestProgram-DolBjSUH.d.ts} +4 -3
  12. package/dist/{TestProgram-DJAm0dIS.d.ts → TestProgram-zI8wr33R.d.ts} +1 -1
  13. package/dist/TestProgram.cjs +28 -31
  14. package/dist/TestProgram.d.cts +3 -2
  15. package/dist/TestProgram.d.ts +3 -2
  16. package/dist/TestProgram.js +3 -3
  17. package/dist/TestRuntime.cjs +2 -1
  18. package/dist/TestRuntime.js +2 -2
  19. package/dist/{Vitest-BiBMIx3C.d.cts → Vitest-2U7CpZsz.d.cts} +1 -1
  20. package/dist/{Vitest-BXBtxem-.d.ts → Vitest-Dr3jUgWl.d.ts} +1 -1
  21. package/dist/Vitest.cjs +30 -32
  22. package/dist/Vitest.d.cts +4 -3
  23. package/dist/Vitest.d.ts +4 -3
  24. package/dist/Vitest.js +4 -4
  25. package/dist/{chunk-CZJ37XWT.js → chunk-3XOKB7L4.js} +25 -29
  26. package/dist/{chunk-DU6VSL4D.js → chunk-5I2BFXGD.js} +3 -2
  27. package/dist/{chunk-NFLRPGHT.js → chunk-AJNVZ6GR.js} +2 -2
  28. package/dist/{chunk-WVD5DTP4.js → chunk-CRWKRQEB.js} +1 -1
  29. package/dist/{chunk-5XFEOVH5.js → chunk-JX3RZZWB.js} +1 -1
  30. package/dist/{chunk-DKT5EFOF.js → chunk-OO3UZI3U.js} +3 -2
  31. package/dist/{chunk-42QGM623.js → chunk-PPQRMDUV.js} +1 -1
  32. package/dist/{chunk-TDYES47J.js → chunk-SP6DKYGN.js} +2 -2
  33. package/dist/index.cjs +32 -34
  34. package/dist/index.d.cts +6 -5
  35. package/dist/index.d.ts +6 -5
  36. package/dist/index.js +8 -8
  37. package/dist/{waitUntil-CjpwZxCu.d.cts → waitUntil-CZQDLJ7j.d.cts} +3 -2
  38. package/dist/{waitUntil-CjpwZxCu.d.ts → waitUntil-CZQDLJ7j.d.ts} +3 -2
  39. package/package.json +11 -6
package/dist/Act.cjs CHANGED
@@ -49,13 +49,13 @@ var flushAllHostScheduler = (scheduler, options) => import_effect.Effect.gen(fun
49
49
  yield* import_effect.Effect.sync(() => {
50
50
  scheduler.flushAll({ maxTurns });
51
51
  });
52
- yield* import_effect.Effect.yieldNow();
52
+ yield* import_effect.Effect.yieldNow;
53
53
  const { microtasks: microtasks2, macrotasks: macrotasks2 } = scheduler.getQueueSize();
54
54
  if (microtasks2 !== 0 || macrotasks2 !== 0) {
55
55
  continue;
56
56
  }
57
57
  for (let i = 0; i < settleYields; i += 1) {
58
- yield* import_effect.Effect.yieldNow();
58
+ yield* import_effect.Effect.yieldNow;
59
59
  }
60
60
  const after = scheduler.getQueueSize();
61
61
  if (after.microtasks === 0 && after.macrotasks === 0) {
package/dist/Act.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  makeTestHostScheduler,
5
5
  testHostSchedulerLayer,
6
6
  tickSchedulerTestLayer
7
- } from "./chunk-NFLRPGHT.js";
7
+ } from "./chunk-AJNVZ6GR.js";
8
8
  import "./chunk-FOYMJMJR.js";
9
9
  export {
10
10
  advanceTicks,
@@ -1,6 +1,6 @@
1
1
  import { Effect } from 'effect';
2
2
  import * as Logix from '@logixjs/core';
3
- import { W as WaitUntilOptions, w as waitUntil } from './waitUntil-CjpwZxCu.cjs';
3
+ import { W as WaitUntilOptions, w as waitUntil } from './waitUntil-CZQDLJ7j.cjs';
4
4
 
5
5
  declare const assertState: <Sh extends Logix.AnyModuleShape>(actual: Logix.StateOf<Sh>, predicate: (s: Logix.StateOf<Sh>) => boolean, message?: string) => Effect.Effect<void, Error>;
6
6
  declare const assertSignal: (actual: unknown, expectedType: string, expectedPayload?: unknown) => Effect.Effect<void, Error>;
@@ -1,6 +1,6 @@
1
1
  import { Effect } from 'effect';
2
2
  import * as Logix from '@logixjs/core';
3
- import { W as WaitUntilOptions, w as waitUntil } from './waitUntil-CjpwZxCu.js';
3
+ import { W as WaitUntilOptions, w as waitUntil } from './waitUntil-CZQDLJ7j.js';
4
4
 
5
5
  declare const assertState: <Sh extends Logix.AnyModuleShape>(actual: Logix.StateOf<Sh>, predicate: (s: Logix.StateOf<Sh>) => boolean, message?: string) => Effect.Effect<void, Error>;
6
6
  declare const assertSignal: (actual: unknown, expectedType: string, expectedPayload?: unknown) => Effect.Effect<void, Error>;
@@ -62,6 +62,7 @@ var assertSignal = (actual, expectedType, expectedPayload) => {
62
62
 
63
63
  // src/internal/utils/waitUntil.ts
64
64
  var import_effect2 = require("effect");
65
+ var import_testing = require("effect/testing");
65
66
  var waitUntil = (check, options = {}) => import_effect2.Effect.gen(function* () {
66
67
  const maxAttempts = options.maxAttempts ?? 20;
67
68
  const step = options.step ?? "10 millis";
@@ -72,8 +73,8 @@ var waitUntil = (check, options = {}) => import_effect2.Effect.gen(function* ()
72
73
  return result.value;
73
74
  }
74
75
  lastError = result.cause;
75
- yield* import_effect2.TestClock.adjust(step);
76
- yield* import_effect2.Effect.yieldNow();
76
+ yield* import_testing.TestClock.adjust(step);
77
+ yield* import_effect2.Effect.yieldNow;
77
78
  }
78
79
  return yield* import_effect2.Effect.fail(lastError);
79
80
  });
@@ -1,4 +1,5 @@
1
- export { a as assertSignal, b as assertState } from './Assertions-uDVCBadW.cjs';
2
- export { W as WaitUntilOptions, w as waitUntil } from './waitUntil-CjpwZxCu.cjs';
1
+ export { a as assertSignal, b as assertState } from './Assertions-CzVzJ0dQ.cjs';
2
+ export { W as WaitUntilOptions, w as waitUntil } from './waitUntil-CZQDLJ7j.cjs';
3
3
  import 'effect';
4
4
  import '@logixjs/core';
5
+ import 'effect/testing';
@@ -1,4 +1,5 @@
1
- export { a as assertSignal, b as assertState } from './Assertions-OpNAhiI_.js';
2
- export { W as WaitUntilOptions, w as waitUntil } from './waitUntil-CjpwZxCu.js';
1
+ export { a as assertSignal, b as assertState } from './Assertions-D2zfasOD.js';
2
+ export { W as WaitUntilOptions, w as waitUntil } from './waitUntil-CZQDLJ7j.js';
3
3
  import 'effect';
4
4
  import '@logixjs/core';
5
+ import 'effect/testing';
@@ -1,9 +1,9 @@
1
- import "./chunk-WVD5DTP4.js";
1
+ import "./chunk-CRWKRQEB.js";
2
2
  import {
3
3
  assertSignal,
4
4
  assertState,
5
5
  waitUntil
6
- } from "./chunk-DU6VSL4D.js";
6
+ } from "./chunk-5I2BFXGD.js";
7
7
  import "./chunk-FOYMJMJR.js";
8
8
  export {
9
9
  assertSignal,
@@ -1,9 +1,10 @@
1
- import { Effect, Duration, TestClock, Scope } from 'effect';
1
+ import { Effect, Duration, Scope } from 'effect';
2
2
  import * as Logix from '@logixjs/core';
3
3
  import { AnyModuleShape } from '@logixjs/core';
4
4
  import { ProgramRunContext, OpenProgramOptions } from '@logixjs/core/Runtime';
5
5
  import { E as ExecutionResult } from './ExecutionResult-BRC-Jzsv.cjs';
6
- import { W as WaitUntilOptions } from './waitUntil-CjpwZxCu.cjs';
6
+ import { TestClock } from 'effect/testing';
7
+ import { W as WaitUntilOptions } from './waitUntil-CZQDLJ7j.cjs';
7
8
 
8
9
  interface TestApi<Sh extends Logix.AnyModuleShape> {
9
10
  readonly ctx: ProgramRunContext<Sh>;
@@ -16,7 +17,7 @@ interface TestApi<Sh extends Logix.AnyModuleShape> {
16
17
  * for time to move forward.
17
18
  * - The runner does not implicitly keep-alive / auto-advance time, keeping time semantics controllable and explainable.
18
19
  */
19
- readonly advance: (duration: Duration.DurationInput) => Effect.Effect<void, never, TestClock.TestClock>;
20
+ readonly advance: (duration: Duration.Input) => Effect.Effect<void, never, TestClock.TestClock>;
20
21
  readonly assert: {
21
22
  readonly state: (predicate: (s: Logix.StateOf<Sh>) => boolean, options?: WaitUntilOptions) => Effect.Effect<void, Error, TestClock.TestClock>;
22
23
  readonly signal: (expectedType: string, expectedPayload?: unknown, options?: WaitUntilOptions) => Effect.Effect<void, Error, TestClock.TestClock>;
@@ -1,4 +1,4 @@
1
- import { T as TestApi, a as TestProgramOptions, r as runProgram } from './TestProgram-BLXiWhJQ.cjs';
1
+ import { T as TestApi, a as TestProgramOptions, r as runProgram } from './TestProgram-BNm-06UK.cjs';
2
2
 
3
3
  declare const TestProgram_TestApi: typeof TestApi;
4
4
  declare const TestProgram_TestProgramOptions: typeof TestProgramOptions;
@@ -1,9 +1,10 @@
1
- import { Effect, Duration, TestClock, Scope } from 'effect';
1
+ import { Effect, Duration, Scope } from 'effect';
2
2
  import * as Logix from '@logixjs/core';
3
3
  import { AnyModuleShape } from '@logixjs/core';
4
4
  import { ProgramRunContext, OpenProgramOptions } from '@logixjs/core/Runtime';
5
5
  import { E as ExecutionResult } from './ExecutionResult-BRC-Jzsv.js';
6
- import { W as WaitUntilOptions } from './waitUntil-CjpwZxCu.js';
6
+ import { TestClock } from 'effect/testing';
7
+ import { W as WaitUntilOptions } from './waitUntil-CZQDLJ7j.js';
7
8
 
8
9
  interface TestApi<Sh extends Logix.AnyModuleShape> {
9
10
  readonly ctx: ProgramRunContext<Sh>;
@@ -16,7 +17,7 @@ interface TestApi<Sh extends Logix.AnyModuleShape> {
16
17
  * for time to move forward.
17
18
  * - The runner does not implicitly keep-alive / auto-advance time, keeping time semantics controllable and explainable.
18
19
  */
19
- readonly advance: (duration: Duration.DurationInput) => Effect.Effect<void, never, TestClock.TestClock>;
20
+ readonly advance: (duration: Duration.Input) => Effect.Effect<void, never, TestClock.TestClock>;
20
21
  readonly assert: {
21
22
  readonly state: (predicate: (s: Logix.StateOf<Sh>) => boolean, options?: WaitUntilOptions) => Effect.Effect<void, Error, TestClock.TestClock>;
22
23
  readonly signal: (expectedType: string, expectedPayload?: unknown, options?: WaitUntilOptions) => Effect.Effect<void, Error, TestClock.TestClock>;
@@ -1,4 +1,4 @@
1
- import { T as TestApi, a as TestProgramOptions, r as runProgram } from './TestProgram-X35n_2Js.js';
1
+ import { T as TestApi, a as TestProgramOptions, r as runProgram } from './TestProgram-DolBjSUH.js';
2
2
 
3
3
  declare const TestProgram_TestApi: typeof TestApi;
4
4
  declare const TestProgram_TestProgramOptions: typeof TestProgramOptions;
@@ -36,6 +36,7 @@ module.exports = __toCommonJS(TestProgram_exports);
36
36
 
37
37
  // src/internal/api/TestProgram.ts
38
38
  var import_effect3 = require("effect");
39
+ var import_testing2 = require("effect/testing");
39
40
  var Logix = __toESM(require("@logixjs/core"), 1);
40
41
 
41
42
  // src/internal/api/ExecutionResult.ts
@@ -81,6 +82,7 @@ var assertSignal = (actual, expectedType, expectedPayload) => {
81
82
 
82
83
  // src/internal/utils/waitUntil.ts
83
84
  var import_effect2 = require("effect");
85
+ var import_testing = require("effect/testing");
84
86
  var waitUntil = (check, options = {}) => import_effect2.Effect.gen(function* () {
85
87
  const maxAttempts = options.maxAttempts ?? 20;
86
88
  const step = options.step ?? "10 millis";
@@ -91,8 +93,8 @@ var waitUntil = (check, options = {}) => import_effect2.Effect.gen(function* ()
91
93
  return result.value;
92
94
  }
93
95
  lastError = result.cause;
94
- yield* import_effect2.TestClock.adjust(step);
95
- yield* import_effect2.Effect.yieldNow();
96
+ yield* import_testing.TestClock.adjust(step);
97
+ yield* import_effect2.Effect.yieldNow;
96
98
  }
97
99
  return yield* import_effect2.Effect.fail(lastError);
98
100
  });
@@ -101,7 +103,7 @@ var waitUntil = (check, options = {}) => import_effect2.Effect.gen(function* ()
101
103
  var defaultOptions = (options) => {
102
104
  const base = options ?? {};
103
105
  const userLayer = base.layer ?? import_effect3.Layer.empty;
104
- const layer = import_effect3.Layer.mergeAll(import_effect3.TestContext.TestContext, userLayer);
106
+ const layer = import_effect3.Layer.mergeAll(import_testing2.TestClock.layer(), userLayer);
105
107
  return {
106
108
  ...base,
107
109
  layer,
@@ -133,7 +135,7 @@ var makeTestApi = (ctx, actionsRef) => {
133
135
  return {
134
136
  ctx,
135
137
  dispatch: ctx.module.dispatch,
136
- advance: (duration) => import_effect3.TestClock.adjust(duration).pipe(import_effect3.Effect.asVoid),
138
+ advance: (duration) => import_testing2.TestClock.adjust(duration).pipe(import_effect3.Effect.asVoid),
137
139
  assert: {
138
140
  state: assertStateEffect,
139
141
  signal: assertSignalEffect
@@ -149,7 +151,7 @@ var startTraceCollectors = (ctx, traceRef, actionsRef) => import_effect3.Effect.
149
151
  yield* import_effect3.Ref.update(traceRef, import_effect3.Chunk.append(event));
150
152
  yield* import_effect3.Ref.update(actionsRef, import_effect3.Chunk.append(action));
151
153
  })
152
- ).pipe(import_effect3.Effect.forkScoped, import_effect3.Scope.extend(ctx.scope));
154
+ ).pipe((effect) => import_effect3.Effect.forkIn(effect, ctx.scope), import_effect3.Effect.asVoid);
153
155
  yield* import_effect3.Stream.runForEach(
154
156
  ctx.module.changes((s) => s),
155
157
  (state) => import_effect3.Effect.gen(function* () {
@@ -157,10 +159,14 @@ var startTraceCollectors = (ctx, traceRef, actionsRef) => import_effect3.Effect.
157
159
  const event = { _tag: "State", state, timestamp };
158
160
  yield* import_effect3.Ref.update(traceRef, import_effect3.Chunk.append(event));
159
161
  })
160
- ).pipe(import_effect3.Effect.forkScoped, import_effect3.Scope.extend(ctx.scope));
161
- yield* import_effect3.TestClock.adjust(1);
162
- yield* import_effect3.Effect.yieldNow();
162
+ ).pipe((effect) => import_effect3.Effect.forkIn(effect, ctx.scope), import_effect3.Effect.asVoid);
163
+ yield* import_testing2.TestClock.adjust(1);
164
+ yield* import_effect3.Effect.yieldNow;
163
165
  });
166
+ var runInProgramScope = (ctx, effect) => import_effect3.Effect.tryPromise({
167
+ try: () => ctx.runtime.runPromise(import_effect3.Effect.provideService(effect, import_effect3.Scope.Scope, ctx.scope)),
168
+ catch: (e) => e
169
+ }).pipe(import_effect3.Effect.orDie);
164
170
  var runProgram = (program, body, options) => import_effect3.Effect.gen(function* () {
165
171
  const traceRef = yield* import_effect3.Ref.make(import_effect3.Chunk.empty());
166
172
  const actionsRef = yield* import_effect3.Ref.make(import_effect3.Chunk.empty());
@@ -181,31 +187,22 @@ var runProgram = (program, body, options) => import_effect3.Effect.gen(function*
181
187
  }
182
188
  };
183
189
  const resolved = defaultOptions(options);
184
- const ctx = yield* import_effect3.Effect.locally(Logix.Debug.internal.currentDebugSinks, [debugSink])(
185
- Logix.Runtime.openProgram(program, resolved)
190
+ const ctx = yield* import_effect3.Effect.provideService(
191
+ Logix.Runtime.openProgram(program, resolved),
192
+ Logix.Debug.internal.currentDebugSinks,
193
+ [debugSink]
186
194
  );
187
- yield* import_effect3.Effect.tryPromise({
188
- try: () => ctx.runtime.runPromise(startTraceCollectors(ctx, traceRef, actionsRef)),
189
- catch: (e) => e
190
- }).pipe(import_effect3.Effect.orDie);
195
+ yield* runInProgramScope(ctx, startTraceCollectors(ctx, traceRef, actionsRef));
191
196
  const api = makeTestApi(ctx, actionsRef);
192
- yield* import_effect3.Effect.tryPromise({
193
- try: () => ctx.runtime.runPromise(body(api).pipe(import_effect3.Scope.extend(ctx.scope))),
194
- catch: (e) => e
195
- }).pipe(import_effect3.Effect.orDie);
196
- yield* import_effect3.Effect.tryPromise({
197
- try: () => ctx.runtime.runPromise(
198
- import_effect3.Effect.gen(function* () {
199
- yield* import_effect3.TestClock.adjust(1);
200
- yield* import_effect3.Effect.yieldNow();
201
- })
202
- ),
203
- catch: (e) => e
204
- }).pipe(import_effect3.Effect.orDie);
205
- const finalState = yield* import_effect3.Effect.tryPromise({
206
- try: () => ctx.runtime.runPromise(ctx.module.getState),
207
- catch: (e) => e
208
- }).pipe(import_effect3.Effect.orDie);
197
+ yield* runInProgramScope(ctx, body(api));
198
+ yield* runInProgramScope(
199
+ ctx,
200
+ import_effect3.Effect.gen(function* () {
201
+ yield* import_testing2.TestClock.adjust(1);
202
+ yield* import_effect3.Effect.yieldNow;
203
+ })
204
+ );
205
+ const finalState = yield* runInProgramScope(ctx, ctx.module.getState);
209
206
  const actionsChunk = yield* import_effect3.Ref.get(actionsRef);
210
207
  const traceChunk = yield* import_effect3.Ref.get(traceRef);
211
208
  return make(
@@ -1,6 +1,7 @@
1
- export { T as TestApi, a as TestProgramOptions, r as runProgram } from './TestProgram-BLXiWhJQ.cjs';
1
+ export { T as TestApi, a as TestProgramOptions, r as runProgram } from './TestProgram-BNm-06UK.cjs';
2
2
  import 'effect';
3
3
  import '@logixjs/core';
4
4
  import '@logixjs/core/Runtime';
5
5
  import './ExecutionResult-BRC-Jzsv.cjs';
6
- import './waitUntil-CjpwZxCu.cjs';
6
+ import 'effect/testing';
7
+ import './waitUntil-CZQDLJ7j.cjs';
@@ -1,6 +1,7 @@
1
- export { T as TestApi, a as TestProgramOptions, r as runProgram } from './TestProgram-X35n_2Js.js';
1
+ export { T as TestApi, a as TestProgramOptions, r as runProgram } from './TestProgram-DolBjSUH.js';
2
2
  import 'effect';
3
3
  import '@logixjs/core';
4
4
  import '@logixjs/core/Runtime';
5
5
  import './ExecutionResult-BRC-Jzsv.js';
6
- import './waitUntil-CjpwZxCu.js';
6
+ import 'effect/testing';
7
+ import './waitUntil-CZQDLJ7j.js';
@@ -1,8 +1,8 @@
1
- import "./chunk-5XFEOVH5.js";
1
+ import "./chunk-JX3RZZWB.js";
2
2
  import {
3
3
  runProgram
4
- } from "./chunk-CZJ37XWT.js";
5
- import "./chunk-DU6VSL4D.js";
4
+ } from "./chunk-3XOKB7L4.js";
5
+ import "./chunk-5I2BFXGD.js";
6
6
  import "./chunk-RG24KSEB.js";
7
7
  import "./chunk-FOYMJMJR.js";
8
8
  export {
@@ -26,8 +26,9 @@ module.exports = __toCommonJS(TestRuntime_exports);
26
26
 
27
27
  // src/internal/runtime/runTest.ts
28
28
  var import_effect = require("effect");
29
+ var import_testing = require("effect/testing");
29
30
  var runTest = (effect) => {
30
- const program = import_effect.Effect.scoped(effect).pipe(import_effect.Effect.provide(import_effect.TestContext.TestContext));
31
+ const program = import_effect.Effect.scoped(effect).pipe(import_effect.Effect.provide(import_testing.TestClock.layer()));
31
32
  return import_effect.Effect.runPromise(program);
32
33
  };
33
34
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,7 +1,7 @@
1
- import "./chunk-42QGM623.js";
1
+ import "./chunk-PPQRMDUV.js";
2
2
  import {
3
3
  runTest
4
- } from "./chunk-DKT5EFOF.js";
4
+ } from "./chunk-OO3UZI3U.js";
5
5
  import "./chunk-FOYMJMJR.js";
6
6
  export {
7
7
  runTest
@@ -1,7 +1,7 @@
1
1
  import { Effect } from 'effect';
2
2
  import * as Logix from '@logixjs/core';
3
3
  import { E as ExecutionResult } from './ExecutionResult-BRC-Jzsv.cjs';
4
- import { T as TestApi, a as TestProgramOptions } from './TestProgram-BLXiWhJQ.cjs';
4
+ import { T as TestApi, a as TestProgramOptions } from './TestProgram-BNm-06UK.cjs';
5
5
 
6
6
  /**
7
7
  * Sugar: defines a program test based on `TestProgram.runProgram`.
@@ -1,7 +1,7 @@
1
1
  import { Effect } from 'effect';
2
2
  import * as Logix from '@logixjs/core';
3
3
  import { E as ExecutionResult } from './ExecutionResult-BRC-Jzsv.js';
4
- import { T as TestApi, a as TestProgramOptions } from './TestProgram-X35n_2Js.js';
4
+ import { T as TestApi, a as TestProgramOptions } from './TestProgram-DolBjSUH.js';
5
5
 
6
6
  /**
7
7
  * Sugar: defines a program test based on `TestProgram.runProgram`.
package/dist/Vitest.cjs CHANGED
@@ -3117,13 +3117,15 @@ var expectNoError = (result) => {
3117
3117
 
3118
3118
  // src/internal/runtime/runTest.ts
3119
3119
  var import_effect = require("effect");
3120
+ var import_testing = require("effect/testing");
3120
3121
  var runTest = (effect) => {
3121
- const program = import_effect.Effect.scoped(effect).pipe(import_effect.Effect.provide(import_effect.TestContext.TestContext));
3122
+ const program = import_effect.Effect.scoped(effect).pipe(import_effect.Effect.provide(import_testing.TestClock.layer()));
3122
3123
  return import_effect.Effect.runPromise(program);
3123
3124
  };
3124
3125
 
3125
3126
  // src/internal/api/TestProgram.ts
3126
3127
  var import_effect4 = require("effect");
3128
+ var import_testing3 = require("effect/testing");
3127
3129
  var Logix = __toESM(require("@logixjs/core"), 1);
3128
3130
 
3129
3131
  // src/internal/utils/assertions.ts
@@ -3162,6 +3164,7 @@ var assertSignal = (actual, expectedType, expectedPayload) => {
3162
3164
 
3163
3165
  // src/internal/utils/waitUntil.ts
3164
3166
  var import_effect3 = require("effect");
3167
+ var import_testing2 = require("effect/testing");
3165
3168
  var waitUntil = (check, options = {}) => import_effect3.Effect.gen(function* () {
3166
3169
  const maxAttempts = options.maxAttempts ?? 20;
3167
3170
  const step = options.step ?? "10 millis";
@@ -3172,8 +3175,8 @@ var waitUntil = (check, options = {}) => import_effect3.Effect.gen(function* ()
3172
3175
  return result.value;
3173
3176
  }
3174
3177
  lastError = result.cause;
3175
- yield* import_effect3.TestClock.adjust(step);
3176
- yield* import_effect3.Effect.yieldNow();
3178
+ yield* import_testing2.TestClock.adjust(step);
3179
+ yield* import_effect3.Effect.yieldNow;
3177
3180
  }
3178
3181
  return yield* import_effect3.Effect.fail(lastError);
3179
3182
  });
@@ -3182,7 +3185,7 @@ var waitUntil = (check, options = {}) => import_effect3.Effect.gen(function* ()
3182
3185
  var defaultOptions = (options) => {
3183
3186
  const base = options ?? {};
3184
3187
  const userLayer = base.layer ?? import_effect4.Layer.empty;
3185
- const layer = import_effect4.Layer.mergeAll(import_effect4.TestContext.TestContext, userLayer);
3188
+ const layer = import_effect4.Layer.mergeAll(import_testing3.TestClock.layer(), userLayer);
3186
3189
  return {
3187
3190
  ...base,
3188
3191
  layer,
@@ -3214,7 +3217,7 @@ var makeTestApi = (ctx, actionsRef) => {
3214
3217
  return {
3215
3218
  ctx,
3216
3219
  dispatch: ctx.module.dispatch,
3217
- advance: (duration) => import_effect4.TestClock.adjust(duration).pipe(import_effect4.Effect.asVoid),
3220
+ advance: (duration) => import_testing3.TestClock.adjust(duration).pipe(import_effect4.Effect.asVoid),
3218
3221
  assert: {
3219
3222
  state: assertStateEffect,
3220
3223
  signal: assertSignalEffect
@@ -3230,7 +3233,7 @@ var startTraceCollectors = (ctx, traceRef, actionsRef) => import_effect4.Effect.
3230
3233
  yield* import_effect4.Ref.update(traceRef, import_effect4.Chunk.append(event));
3231
3234
  yield* import_effect4.Ref.update(actionsRef, import_effect4.Chunk.append(action));
3232
3235
  })
3233
- ).pipe(import_effect4.Effect.forkScoped, import_effect4.Scope.extend(ctx.scope));
3236
+ ).pipe((effect) => import_effect4.Effect.forkIn(effect, ctx.scope), import_effect4.Effect.asVoid);
3234
3237
  yield* import_effect4.Stream.runForEach(
3235
3238
  ctx.module.changes((s) => s),
3236
3239
  (state) => import_effect4.Effect.gen(function* () {
@@ -3238,10 +3241,14 @@ var startTraceCollectors = (ctx, traceRef, actionsRef) => import_effect4.Effect.
3238
3241
  const event = { _tag: "State", state, timestamp };
3239
3242
  yield* import_effect4.Ref.update(traceRef, import_effect4.Chunk.append(event));
3240
3243
  })
3241
- ).pipe(import_effect4.Effect.forkScoped, import_effect4.Scope.extend(ctx.scope));
3242
- yield* import_effect4.TestClock.adjust(1);
3243
- yield* import_effect4.Effect.yieldNow();
3244
+ ).pipe((effect) => import_effect4.Effect.forkIn(effect, ctx.scope), import_effect4.Effect.asVoid);
3245
+ yield* import_testing3.TestClock.adjust(1);
3246
+ yield* import_effect4.Effect.yieldNow;
3244
3247
  });
3248
+ var runInProgramScope = (ctx, effect) => import_effect4.Effect.tryPromise({
3249
+ try: () => ctx.runtime.runPromise(import_effect4.Effect.provideService(effect, import_effect4.Scope.Scope, ctx.scope)),
3250
+ catch: (e) => e
3251
+ }).pipe(import_effect4.Effect.orDie);
3245
3252
  var runProgram = (program, body, options) => import_effect4.Effect.gen(function* () {
3246
3253
  const traceRef = yield* import_effect4.Ref.make(import_effect4.Chunk.empty());
3247
3254
  const actionsRef = yield* import_effect4.Ref.make(import_effect4.Chunk.empty());
@@ -3262,31 +3269,22 @@ var runProgram = (program, body, options) => import_effect4.Effect.gen(function*
3262
3269
  }
3263
3270
  };
3264
3271
  const resolved = defaultOptions(options);
3265
- const ctx = yield* import_effect4.Effect.locally(Logix.Debug.internal.currentDebugSinks, [debugSink])(
3266
- Logix.Runtime.openProgram(program, resolved)
3272
+ const ctx = yield* import_effect4.Effect.provideService(
3273
+ Logix.Runtime.openProgram(program, resolved),
3274
+ Logix.Debug.internal.currentDebugSinks,
3275
+ [debugSink]
3267
3276
  );
3268
- yield* import_effect4.Effect.tryPromise({
3269
- try: () => ctx.runtime.runPromise(startTraceCollectors(ctx, traceRef, actionsRef)),
3270
- catch: (e) => e
3271
- }).pipe(import_effect4.Effect.orDie);
3277
+ yield* runInProgramScope(ctx, startTraceCollectors(ctx, traceRef, actionsRef));
3272
3278
  const api = makeTestApi(ctx, actionsRef);
3273
- yield* import_effect4.Effect.tryPromise({
3274
- try: () => ctx.runtime.runPromise(body(api).pipe(import_effect4.Scope.extend(ctx.scope))),
3275
- catch: (e) => e
3276
- }).pipe(import_effect4.Effect.orDie);
3277
- yield* import_effect4.Effect.tryPromise({
3278
- try: () => ctx.runtime.runPromise(
3279
- import_effect4.Effect.gen(function* () {
3280
- yield* import_effect4.TestClock.adjust(1);
3281
- yield* import_effect4.Effect.yieldNow();
3282
- })
3283
- ),
3284
- catch: (e) => e
3285
- }).pipe(import_effect4.Effect.orDie);
3286
- const finalState = yield* import_effect4.Effect.tryPromise({
3287
- try: () => ctx.runtime.runPromise(ctx.module.getState),
3288
- catch: (e) => e
3289
- }).pipe(import_effect4.Effect.orDie);
3279
+ yield* runInProgramScope(ctx, body(api));
3280
+ yield* runInProgramScope(
3281
+ ctx,
3282
+ import_effect4.Effect.gen(function* () {
3283
+ yield* import_testing3.TestClock.adjust(1);
3284
+ yield* import_effect4.Effect.yieldNow;
3285
+ })
3286
+ );
3287
+ const finalState = yield* runInProgramScope(ctx, ctx.module.getState);
3290
3288
  const actionsChunk = yield* import_effect4.Ref.get(actionsRef);
3291
3289
  const traceChunk = yield* import_effect4.Ref.get(traceRef);
3292
3290
  return make(
package/dist/Vitest.d.cts CHANGED
@@ -1,7 +1,8 @@
1
- export { i as itProgram, a as itProgramResult } from './Vitest-BiBMIx3C.cjs';
1
+ export { i as itProgram, a as itProgramResult } from './Vitest-2U7CpZsz.cjs';
2
2
  import 'effect';
3
3
  import '@logixjs/core';
4
4
  import './ExecutionResult-BRC-Jzsv.cjs';
5
- import './TestProgram-BLXiWhJQ.cjs';
5
+ import './TestProgram-BNm-06UK.cjs';
6
6
  import '@logixjs/core/Runtime';
7
- import './waitUntil-CjpwZxCu.cjs';
7
+ import 'effect/testing';
8
+ import './waitUntil-CZQDLJ7j.cjs';
package/dist/Vitest.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- export { i as itProgram, a as itProgramResult } from './Vitest-BXBtxem-.js';
1
+ export { i as itProgram, a as itProgramResult } from './Vitest-Dr3jUgWl.js';
2
2
  import 'effect';
3
3
  import '@logixjs/core';
4
4
  import './ExecutionResult-BRC-Jzsv.js';
5
- import './TestProgram-X35n_2Js.js';
5
+ import './TestProgram-DolBjSUH.js';
6
6
  import '@logixjs/core/Runtime';
7
- import './waitUntil-CjpwZxCu.js';
7
+ import 'effect/testing';
8
+ import './waitUntil-CZQDLJ7j.js';
package/dist/Vitest.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  itProgram,
3
3
  itProgramResult
4
- } from "./chunk-TDYES47J.js";
5
- import "./chunk-CZJ37XWT.js";
6
- import "./chunk-DU6VSL4D.js";
4
+ } from "./chunk-SP6DKYGN.js";
5
+ import "./chunk-3XOKB7L4.js";
6
+ import "./chunk-5I2BFXGD.js";
7
7
  import "./chunk-RG24KSEB.js";
8
- import "./chunk-DKT5EFOF.js";
8
+ import "./chunk-OO3UZI3U.js";
9
9
  import "./chunk-FOYMJMJR.js";
10
10
  export {
11
11
  itProgram,
@@ -2,18 +2,19 @@ import {
2
2
  assertSignal,
3
3
  assertState,
4
4
  waitUntil
5
- } from "./chunk-DU6VSL4D.js";
5
+ } from "./chunk-5I2BFXGD.js";
6
6
  import {
7
7
  make
8
8
  } from "./chunk-RG24KSEB.js";
9
9
 
10
10
  // src/internal/api/TestProgram.ts
11
- import { Chunk, Clock, Effect, Layer, Ref, Scope, Stream, TestClock, TestContext } from "effect";
11
+ import { Chunk, Clock, Effect, Layer, Ref, Scope, Stream } from "effect";
12
+ import { TestClock } from "effect/testing";
12
13
  import * as Logix from "@logixjs/core";
13
14
  var defaultOptions = (options) => {
14
15
  const base = options ?? {};
15
16
  const userLayer = base.layer ?? Layer.empty;
16
- const layer = Layer.mergeAll(TestContext.TestContext, userLayer);
17
+ const layer = Layer.mergeAll(TestClock.layer(), userLayer);
17
18
  return {
18
19
  ...base,
19
20
  layer,
@@ -61,7 +62,7 @@ var startTraceCollectors = (ctx, traceRef, actionsRef) => Effect.gen(function* (
61
62
  yield* Ref.update(traceRef, Chunk.append(event));
62
63
  yield* Ref.update(actionsRef, Chunk.append(action));
63
64
  })
64
- ).pipe(Effect.forkScoped, Scope.extend(ctx.scope));
65
+ ).pipe((effect) => Effect.forkIn(effect, ctx.scope), Effect.asVoid);
65
66
  yield* Stream.runForEach(
66
67
  ctx.module.changes((s) => s),
67
68
  (state) => Effect.gen(function* () {
@@ -69,10 +70,14 @@ var startTraceCollectors = (ctx, traceRef, actionsRef) => Effect.gen(function* (
69
70
  const event = { _tag: "State", state, timestamp };
70
71
  yield* Ref.update(traceRef, Chunk.append(event));
71
72
  })
72
- ).pipe(Effect.forkScoped, Scope.extend(ctx.scope));
73
+ ).pipe((effect) => Effect.forkIn(effect, ctx.scope), Effect.asVoid);
73
74
  yield* TestClock.adjust(1);
74
- yield* Effect.yieldNow();
75
+ yield* Effect.yieldNow;
75
76
  });
77
+ var runInProgramScope = (ctx, effect) => Effect.tryPromise({
78
+ try: () => ctx.runtime.runPromise(Effect.provideService(effect, Scope.Scope, ctx.scope)),
79
+ catch: (e) => e
80
+ }).pipe(Effect.orDie);
76
81
  var runProgram = (program, body, options) => Effect.gen(function* () {
77
82
  const traceRef = yield* Ref.make(Chunk.empty());
78
83
  const actionsRef = yield* Ref.make(Chunk.empty());
@@ -93,31 +98,22 @@ var runProgram = (program, body, options) => Effect.gen(function* () {
93
98
  }
94
99
  };
95
100
  const resolved = defaultOptions(options);
96
- const ctx = yield* Effect.locally(Logix.Debug.internal.currentDebugSinks, [debugSink])(
97
- Logix.Runtime.openProgram(program, resolved)
101
+ const ctx = yield* Effect.provideService(
102
+ Logix.Runtime.openProgram(program, resolved),
103
+ Logix.Debug.internal.currentDebugSinks,
104
+ [debugSink]
98
105
  );
99
- yield* Effect.tryPromise({
100
- try: () => ctx.runtime.runPromise(startTraceCollectors(ctx, traceRef, actionsRef)),
101
- catch: (e) => e
102
- }).pipe(Effect.orDie);
106
+ yield* runInProgramScope(ctx, startTraceCollectors(ctx, traceRef, actionsRef));
103
107
  const api = makeTestApi(ctx, actionsRef);
104
- yield* Effect.tryPromise({
105
- try: () => ctx.runtime.runPromise(body(api).pipe(Scope.extend(ctx.scope))),
106
- catch: (e) => e
107
- }).pipe(Effect.orDie);
108
- yield* Effect.tryPromise({
109
- try: () => ctx.runtime.runPromise(
110
- Effect.gen(function* () {
111
- yield* TestClock.adjust(1);
112
- yield* Effect.yieldNow();
113
- })
114
- ),
115
- catch: (e) => e
116
- }).pipe(Effect.orDie);
117
- const finalState = yield* Effect.tryPromise({
118
- try: () => ctx.runtime.runPromise(ctx.module.getState),
119
- catch: (e) => e
120
- }).pipe(Effect.orDie);
108
+ yield* runInProgramScope(ctx, body(api));
109
+ yield* runInProgramScope(
110
+ ctx,
111
+ Effect.gen(function* () {
112
+ yield* TestClock.adjust(1);
113
+ yield* Effect.yieldNow;
114
+ })
115
+ );
116
+ const finalState = yield* runInProgramScope(ctx, ctx.module.getState);
121
117
  const actionsChunk = yield* Ref.get(actionsRef);
122
118
  const traceChunk = yield* Ref.get(traceRef);
123
119
  return make(
@@ -33,7 +33,8 @@ var assertSignal = (actual, expectedType, expectedPayload) => {
33
33
  };
34
34
 
35
35
  // src/internal/utils/waitUntil.ts
36
- import { Effect as Effect2, TestClock } from "effect";
36
+ import { Effect as Effect2 } from "effect";
37
+ import { TestClock } from "effect/testing";
37
38
  var waitUntil = (check, options = {}) => Effect2.gen(function* () {
38
39
  const maxAttempts = options.maxAttempts ?? 20;
39
40
  const step = options.step ?? "10 millis";
@@ -45,7 +46,7 @@ var waitUntil = (check, options = {}) => Effect2.gen(function* () {
45
46
  }
46
47
  lastError = result.cause;
47
48
  yield* TestClock.adjust(step);
48
- yield* Effect2.yieldNow();
49
+ yield* Effect2.yieldNow;
49
50
  }
50
51
  return yield* Effect2.fail(lastError);
51
52
  });
@@ -23,13 +23,13 @@ var flushAllHostScheduler = (scheduler, options) => Effect.gen(function* () {
23
23
  yield* Effect.sync(() => {
24
24
  scheduler.flushAll({ maxTurns });
25
25
  });
26
- yield* Effect.yieldNow();
26
+ yield* Effect.yieldNow;
27
27
  const { microtasks: microtasks2, macrotasks: macrotasks2 } = scheduler.getQueueSize();
28
28
  if (microtasks2 !== 0 || macrotasks2 !== 0) {
29
29
  continue;
30
30
  }
31
31
  for (let i = 0; i < settleYields; i += 1) {
32
- yield* Effect.yieldNow();
32
+ yield* Effect.yieldNow;
33
33
  }
34
34
  const after = scheduler.getQueueSize();
35
35
  if (after.microtasks === 0 && after.macrotasks === 0) {
@@ -2,7 +2,7 @@ import {
2
2
  assertSignal,
3
3
  assertState,
4
4
  waitUntil
5
- } from "./chunk-DU6VSL4D.js";
5
+ } from "./chunk-5I2BFXGD.js";
6
6
  import {
7
7
  __export
8
8
  } from "./chunk-FOYMJMJR.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runProgram
3
- } from "./chunk-CZJ37XWT.js";
3
+ } from "./chunk-3XOKB7L4.js";
4
4
  import {
5
5
  __export
6
6
  } from "./chunk-FOYMJMJR.js";
@@ -1,7 +1,8 @@
1
1
  // src/internal/runtime/runTest.ts
2
- import { Effect, TestContext } from "effect";
2
+ import { Effect } from "effect";
3
+ import { TestClock } from "effect/testing";
3
4
  var runTest = (effect) => {
4
- const program = Effect.scoped(effect).pipe(Effect.provide(TestContext.TestContext));
5
+ const program = Effect.scoped(effect).pipe(Effect.provide(TestClock.layer()));
5
6
  return Effect.runPromise(program);
6
7
  };
7
8
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runTest
3
- } from "./chunk-DKT5EFOF.js";
3
+ } from "./chunk-OO3UZI3U.js";
4
4
  import {
5
5
  __export
6
6
  } from "./chunk-FOYMJMJR.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  runProgram
3
- } from "./chunk-CZJ37XWT.js";
3
+ } from "./chunk-3XOKB7L4.js";
4
4
  import {
5
5
  expectNoError
6
6
  } from "./chunk-RG24KSEB.js";
7
7
  import {
8
8
  runTest
9
- } from "./chunk-DKT5EFOF.js";
9
+ } from "./chunk-OO3UZI3U.js";
10
10
  import {
11
11
  __commonJS,
12
12
  __export,
package/dist/index.cjs CHANGED
@@ -164,8 +164,9 @@ __export(TestRuntime_exports, {
164
164
 
165
165
  // src/internal/runtime/runTest.ts
166
166
  var import_effect = require("effect");
167
+ var import_testing = require("effect/testing");
167
168
  var runTest = (effect) => {
168
- const program = import_effect.Effect.scoped(effect).pipe(import_effect.Effect.provide(import_effect.TestContext.TestContext));
169
+ const program = import_effect.Effect.scoped(effect).pipe(import_effect.Effect.provide(import_testing.TestClock.layer()));
169
170
  return import_effect.Effect.runPromise(program);
170
171
  };
171
172
 
@@ -177,6 +178,7 @@ __export(TestProgram_exports, {
177
178
 
178
179
  // src/internal/api/TestProgram.ts
179
180
  var import_effect4 = require("effect");
181
+ var import_testing3 = require("effect/testing");
180
182
  var Logix = __toESM(require("@logixjs/core"), 1);
181
183
 
182
184
  // src/internal/api/ExecutionResult.ts
@@ -268,6 +270,7 @@ var assertSignal = (actual, expectedType, expectedPayload) => {
268
270
 
269
271
  // src/internal/utils/waitUntil.ts
270
272
  var import_effect3 = require("effect");
273
+ var import_testing2 = require("effect/testing");
271
274
  var waitUntil = (check, options = {}) => import_effect3.Effect.gen(function* () {
272
275
  const maxAttempts = options.maxAttempts ?? 20;
273
276
  const step = options.step ?? "10 millis";
@@ -278,8 +281,8 @@ var waitUntil = (check, options = {}) => import_effect3.Effect.gen(function* ()
278
281
  return result.value;
279
282
  }
280
283
  lastError = result.cause;
281
- yield* import_effect3.TestClock.adjust(step);
282
- yield* import_effect3.Effect.yieldNow();
284
+ yield* import_testing2.TestClock.adjust(step);
285
+ yield* import_effect3.Effect.yieldNow;
283
286
  }
284
287
  return yield* import_effect3.Effect.fail(lastError);
285
288
  });
@@ -288,7 +291,7 @@ var waitUntil = (check, options = {}) => import_effect3.Effect.gen(function* ()
288
291
  var defaultOptions = (options) => {
289
292
  const base = options ?? {};
290
293
  const userLayer = base.layer ?? import_effect4.Layer.empty;
291
- const layer = import_effect4.Layer.mergeAll(import_effect4.TestContext.TestContext, userLayer);
294
+ const layer = import_effect4.Layer.mergeAll(import_testing3.TestClock.layer(), userLayer);
292
295
  return {
293
296
  ...base,
294
297
  layer,
@@ -320,7 +323,7 @@ var makeTestApi = (ctx, actionsRef) => {
320
323
  return {
321
324
  ctx,
322
325
  dispatch: ctx.module.dispatch,
323
- advance: (duration) => import_effect4.TestClock.adjust(duration).pipe(import_effect4.Effect.asVoid),
326
+ advance: (duration) => import_testing3.TestClock.adjust(duration).pipe(import_effect4.Effect.asVoid),
324
327
  assert: {
325
328
  state: assertStateEffect,
326
329
  signal: assertSignalEffect
@@ -336,7 +339,7 @@ var startTraceCollectors = (ctx, traceRef, actionsRef) => import_effect4.Effect.
336
339
  yield* import_effect4.Ref.update(traceRef, import_effect4.Chunk.append(event));
337
340
  yield* import_effect4.Ref.update(actionsRef, import_effect4.Chunk.append(action));
338
341
  })
339
- ).pipe(import_effect4.Effect.forkScoped, import_effect4.Scope.extend(ctx.scope));
342
+ ).pipe((effect) => import_effect4.Effect.forkIn(effect, ctx.scope), import_effect4.Effect.asVoid);
340
343
  yield* import_effect4.Stream.runForEach(
341
344
  ctx.module.changes((s) => s),
342
345
  (state) => import_effect4.Effect.gen(function* () {
@@ -344,10 +347,14 @@ var startTraceCollectors = (ctx, traceRef, actionsRef) => import_effect4.Effect.
344
347
  const event = { _tag: "State", state, timestamp };
345
348
  yield* import_effect4.Ref.update(traceRef, import_effect4.Chunk.append(event));
346
349
  })
347
- ).pipe(import_effect4.Effect.forkScoped, import_effect4.Scope.extend(ctx.scope));
348
- yield* import_effect4.TestClock.adjust(1);
349
- yield* import_effect4.Effect.yieldNow();
350
+ ).pipe((effect) => import_effect4.Effect.forkIn(effect, ctx.scope), import_effect4.Effect.asVoid);
351
+ yield* import_testing3.TestClock.adjust(1);
352
+ yield* import_effect4.Effect.yieldNow;
350
353
  });
354
+ var runInProgramScope = (ctx, effect) => import_effect4.Effect.tryPromise({
355
+ try: () => ctx.runtime.runPromise(import_effect4.Effect.provideService(effect, import_effect4.Scope.Scope, ctx.scope)),
356
+ catch: (e) => e
357
+ }).pipe(import_effect4.Effect.orDie);
351
358
  var runProgram = (program, body, options) => import_effect4.Effect.gen(function* () {
352
359
  const traceRef = yield* import_effect4.Ref.make(import_effect4.Chunk.empty());
353
360
  const actionsRef = yield* import_effect4.Ref.make(import_effect4.Chunk.empty());
@@ -368,31 +375,22 @@ var runProgram = (program, body, options) => import_effect4.Effect.gen(function*
368
375
  }
369
376
  };
370
377
  const resolved = defaultOptions(options);
371
- const ctx = yield* import_effect4.Effect.locally(Logix.Debug.internal.currentDebugSinks, [debugSink])(
372
- Logix.Runtime.openProgram(program, resolved)
378
+ const ctx = yield* import_effect4.Effect.provideService(
379
+ Logix.Runtime.openProgram(program, resolved),
380
+ Logix.Debug.internal.currentDebugSinks,
381
+ [debugSink]
373
382
  );
374
- yield* import_effect4.Effect.tryPromise({
375
- try: () => ctx.runtime.runPromise(startTraceCollectors(ctx, traceRef, actionsRef)),
376
- catch: (e) => e
377
- }).pipe(import_effect4.Effect.orDie);
383
+ yield* runInProgramScope(ctx, startTraceCollectors(ctx, traceRef, actionsRef));
378
384
  const api = makeTestApi(ctx, actionsRef);
379
- yield* import_effect4.Effect.tryPromise({
380
- try: () => ctx.runtime.runPromise(body(api).pipe(import_effect4.Scope.extend(ctx.scope))),
381
- catch: (e) => e
382
- }).pipe(import_effect4.Effect.orDie);
383
- yield* import_effect4.Effect.tryPromise({
384
- try: () => ctx.runtime.runPromise(
385
- import_effect4.Effect.gen(function* () {
386
- yield* import_effect4.TestClock.adjust(1);
387
- yield* import_effect4.Effect.yieldNow();
388
- })
389
- ),
390
- catch: (e) => e
391
- }).pipe(import_effect4.Effect.orDie);
392
- const finalState = yield* import_effect4.Effect.tryPromise({
393
- try: () => ctx.runtime.runPromise(ctx.module.getState),
394
- catch: (e) => e
395
- }).pipe(import_effect4.Effect.orDie);
385
+ yield* runInProgramScope(ctx, body(api));
386
+ yield* runInProgramScope(
387
+ ctx,
388
+ import_effect4.Effect.gen(function* () {
389
+ yield* import_testing3.TestClock.adjust(1);
390
+ yield* import_effect4.Effect.yieldNow;
391
+ })
392
+ );
393
+ const finalState = yield* runInProgramScope(ctx, ctx.module.getState);
396
394
  const actionsChunk = yield* import_effect4.Ref.get(actionsRef);
397
395
  const traceChunk = yield* import_effect4.Ref.get(traceRef);
398
396
  return make(
@@ -3415,13 +3413,13 @@ var flushAllHostScheduler = (scheduler, options) => import_effect5.Effect.gen(fu
3415
3413
  yield* import_effect5.Effect.sync(() => {
3416
3414
  scheduler.flushAll({ maxTurns });
3417
3415
  });
3418
- yield* import_effect5.Effect.yieldNow();
3416
+ yield* import_effect5.Effect.yieldNow;
3419
3417
  const { microtasks: microtasks2, macrotasks: macrotasks2 } = scheduler.getQueueSize();
3420
3418
  if (microtasks2 !== 0 || macrotasks2 !== 0) {
3421
3419
  continue;
3422
3420
  }
3423
3421
  for (let i = 0; i < settleYields; i += 1) {
3424
- yield* import_effect5.Effect.yieldNow();
3422
+ yield* import_effect5.Effect.yieldNow;
3425
3423
  }
3426
3424
  const after = scheduler.getQueueSize();
3427
3425
  if (after.microtasks === 0 && after.macrotasks === 0) {
package/dist/index.d.cts CHANGED
@@ -1,12 +1,13 @@
1
1
  export { T as TestRuntime } from './TestRuntime-CyYCUXdT.cjs';
2
- export { T as TestProgram } from './TestProgram-CPvVAbfI.cjs';
2
+ export { T as TestProgram } from './TestProgram-DHhYdhOm.cjs';
3
3
  export { E as Execution } from './Execution-FfEGGSS7.cjs';
4
- export { A as Assertions } from './Assertions-uDVCBadW.cjs';
5
- export { V as Vitest } from './Vitest-BiBMIx3C.cjs';
4
+ export { A as Assertions } from './Assertions-CzVzJ0dQ.cjs';
5
+ export { V as Vitest } from './Vitest-2U7CpZsz.cjs';
6
6
  export { A as Act } from './Act-65bCRtuC.cjs';
7
7
  import 'effect';
8
- import './TestProgram-BLXiWhJQ.cjs';
8
+ import './TestProgram-BNm-06UK.cjs';
9
9
  import '@logixjs/core';
10
10
  import '@logixjs/core/Runtime';
11
11
  import './ExecutionResult-BRC-Jzsv.cjs';
12
- import './waitUntil-CjpwZxCu.cjs';
12
+ import 'effect/testing';
13
+ import './waitUntil-CZQDLJ7j.cjs';
package/dist/index.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  export { T as TestRuntime } from './TestRuntime-CyYCUXdT.js';
2
- export { T as TestProgram } from './TestProgram-DJAm0dIS.js';
2
+ export { T as TestProgram } from './TestProgram-zI8wr33R.js';
3
3
  export { E as Execution } from './Execution-Cu-n-UYb.js';
4
- export { A as Assertions } from './Assertions-OpNAhiI_.js';
5
- export { V as Vitest } from './Vitest-BXBtxem-.js';
4
+ export { A as Assertions } from './Assertions-D2zfasOD.js';
5
+ export { V as Vitest } from './Vitest-Dr3jUgWl.js';
6
6
  export { A as Act } from './Act-65bCRtuC.js';
7
7
  import 'effect';
8
- import './TestProgram-X35n_2Js.js';
8
+ import './TestProgram-DolBjSUH.js';
9
9
  import '@logixjs/core';
10
10
  import '@logixjs/core/Runtime';
11
11
  import './ExecutionResult-BRC-Jzsv.js';
12
- import './waitUntil-CjpwZxCu.js';
12
+ import 'effect/testing';
13
+ import './waitUntil-CZQDLJ7j.js';
package/dist/index.js CHANGED
@@ -1,25 +1,25 @@
1
1
  import {
2
2
  Act_exports
3
- } from "./chunk-NFLRPGHT.js";
3
+ } from "./chunk-AJNVZ6GR.js";
4
4
  import {
5
5
  Assertions_exports
6
- } from "./chunk-WVD5DTP4.js";
6
+ } from "./chunk-CRWKRQEB.js";
7
7
  import {
8
8
  Execution_exports
9
9
  } from "./chunk-J5AZHNSA.js";
10
10
  import {
11
11
  TestProgram_exports
12
- } from "./chunk-5XFEOVH5.js";
12
+ } from "./chunk-JX3RZZWB.js";
13
13
  import {
14
14
  TestRuntime_exports
15
- } from "./chunk-42QGM623.js";
15
+ } from "./chunk-PPQRMDUV.js";
16
16
  import {
17
17
  Vitest_exports
18
- } from "./chunk-TDYES47J.js";
19
- import "./chunk-CZJ37XWT.js";
20
- import "./chunk-DU6VSL4D.js";
18
+ } from "./chunk-SP6DKYGN.js";
19
+ import "./chunk-3XOKB7L4.js";
20
+ import "./chunk-5I2BFXGD.js";
21
21
  import "./chunk-RG24KSEB.js";
22
- import "./chunk-DKT5EFOF.js";
22
+ import "./chunk-OO3UZI3U.js";
23
23
  import "./chunk-FOYMJMJR.js";
24
24
  export {
25
25
  Act_exports as Act,
@@ -1,8 +1,9 @@
1
- import { Effect, Duration, TestClock } from 'effect';
1
+ import { Effect, Duration } from 'effect';
2
+ import { TestClock } from 'effect/testing';
2
3
 
3
4
  interface WaitUntilOptions {
4
5
  readonly maxAttempts?: number;
5
- readonly step?: Duration.DurationInput;
6
+ readonly step?: Duration.Input;
6
7
  }
7
8
  /**
8
9
  * Repeatedly runs an assertion under TestContext by advancing TestClock and yielding the scheduler,
@@ -1,8 +1,9 @@
1
- import { Effect, Duration, TestClock } from 'effect';
1
+ import { Effect, Duration } from 'effect';
2
+ import { TestClock } from 'effect/testing';
2
3
 
3
4
  interface WaitUntilOptions {
4
5
  readonly maxAttempts?: number;
5
- readonly step?: Duration.DurationInput;
6
+ readonly step?: Duration.Input;
6
7
  }
7
8
  /**
8
9
  * Repeatedly runs an assertion under TestContext by advancing TestClock and yielding the scheduler,
package/package.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "name": "@logixjs/test",
3
- "version": "0.0.2",
3
+ "version": "1.0.1",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/yoyooyooo/logix",
7
+ "directory": "packages/logix-test"
8
+ },
4
9
  "license": "Apache-2.0",
5
10
  "description": "Testing utilities for Logix v3",
6
11
  "files": [
@@ -48,18 +53,18 @@
48
53
  "access": "public"
49
54
  },
50
55
  "dependencies": {
51
- "effect": "^3.19.8",
52
- "@logixjs/core": "0.0.2"
56
+ "effect": "4.0.0-beta.28",
57
+ "@logixjs/core": "1.0.1"
53
58
  },
54
59
  "devDependencies": {
55
- "@effect/vitest": "^0.27.0",
60
+ "@effect/vitest": "4.0.0-beta.28",
56
61
  "tsup": "^8.0.0",
57
62
  "typescript": "^5.4.0",
58
63
  "vitest": "^4.0.15"
59
64
  },
60
65
  "peerDependencies": {
61
- "effect": "^3.19.8",
62
- "@logixjs/core": "0.0.2"
66
+ "effect": "4.0.0-beta.28",
67
+ "@logixjs/core": "1.0.1"
63
68
  },
64
69
  "scripts": {
65
70
  "build": "tsup",