You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const it =testEffect(Layer.mergeAll(MyService.defaultLayer))
96
+
97
+
describe("my service", () => {
98
+
it.live("does the thing", () =>
99
+
provideTmpdirInstance(() =>
100
+
Effect.gen(function* () {
101
+
const svc =yield*MyService.Service
102
+
const out =yield*svc.run()
103
+
expect(out).toEqual("ok")
104
+
}),
105
+
),
106
+
)
107
+
})
108
+
```
109
+
110
+
### `it.effect` vs `it.live`
111
+
112
+
- Use `it.effect(...)` when the test should run with `TestClock` and `TestConsole`.
113
+
- Use `it.live(...)` when the test depends on real time, filesystem mtimes, child processes, git, locks, or other live OS behavior.
114
+
- Most integration-style tests in this package use `it.live(...)`.
115
+
116
+
### Effect Fixtures
117
+
118
+
Prefer the Effect-aware helpers from `fixture/fixture.ts` instead of building a manual runtime in each test.
119
+
120
+
-`tmpdirScoped(options?)` creates a scoped temp directory and cleans it up when the Effect scope closes.
121
+
-`provideInstance(dir)(effect)` is the low-level helper. It does not create a directory; it just runs an Effect with `Instance.current` bound to `dir`.
122
+
-`provideTmpdirInstance((dir) => effect, options?)` is the convenience helper. It creates a temp directory, binds it as the active instance, and disposes the instance on cleanup.
123
+
-`provideTmpdirServer((input) => effect, options?)` does the same, but also provides the test LLM server.
124
+
125
+
Use `provideTmpdirInstance(...)` by default when a test only needs one temp instance. Use `tmpdirScoped()` plus `provideInstance(...)` when a test needs multiple directories, custom setup before binding, or needs to switch instance context within one test.
126
+
127
+
### Style
128
+
129
+
- Define `const it = testEffect(...)` near the top of the file.
130
+
- Keep the test body inside `Effect.gen(function* () { ... })`.
131
+
- Yield services directly with `yield* MyService.Service` or `yield* MyTool`.
132
+
- Avoid custom `ManagedRuntime`, `attach(...)`, or ad hoc `run(...)` wrappers when `testEffect(...)` already provides the runtime.
133
+
- When a test needs instance-local state, prefer `provideTmpdirInstance(...)` or `provideInstance(...)` over manual `Instance.provide(...)` inside Promise-style tests.
0 commit comments