Testing patterns with layers, mocks, and deterministic time. Use when preparing testable services and small smoke tests.
const RepoTest = Layer.succeed(Repo, Repo.of({ find: () => Effect.succeed(mock) }))
const result = yield* Effect.provide(program, RepoTest)
// Provide a deterministic Clock or use platform TestClock layer if available
.Default layers for quick wiring; add custom mock layers per testCRITICAL: Search local Effect source before implementing
The full Effect source code is available at docs/effect-source/. Always search the actual implementation before writing Effect code.
docs/effect-source/effect/src/Layer.tsdocs/effect-source/effect/src/TestClock.tsdocs/effect-source/effect/src/TestContext.ts# Find Layer.succeed patterns for mocks
grep -F "Layer.succeed" docs/effect-source/effect/src/Layer.ts
# Study TestClock operations
grep -F "TestClock" docs/effect-source/effect/src/TestClock.ts
# Find test helpers
grep -F "TestContext" docs/effect-source/effect/src/TestContext.ts
# Look at Layer test examples
grep -F "Layer.succeed" docs/effect-source/effect/test/Layer.test.ts
docs/effect-source/effect/src/Layer.ts for the implementationReal source code > documentation > assumptions
export const TestLayer = (input?: TestLiveInput) =>
Effect.gen(function* () {
const tempDir = tempy.temporaryDirectory({ prefix: 'test' })
const cwd = (yield* setupFixtureFolder({ fixture: input?.fixture, tempDir })) ?? tempDir
const NodeOsTest = Layer.succeed(NodeOs, new NodeOs({ homedir: cwd, arch: 'arm64', platform: 'darwin' }))
const NodeProcessTest = Layer.succeed(NodeProcess, new NodeProcess({ cwd, platform: 'darwin', arch: 'arm64' }))
const ToolkitsRepoTest = Layer.succeed(ComposioToolkitsRepository, new ComposioToolkitsRepository({
getToolkits: () => Effect.succeed([]),
getToolsAsEnums: () => Effect.succeed([])
}))
const layers = Layer.mergeAll(
Console.setConsole(yield* MockConsole.effect),
CliConfig.layer(ComposioCliConfig),
NodeProcessTest,
Layer.provideMerge(ComposioUserContextLive, Layer.merge(BunFileSystem.layer, NodeOsTest)),
ToolkitsRepoTest,
EnvLangDetector.Default,
JsPackageManagerDetector.Default,
BunFileSystem.layer,
BunContext.layer,
MockTerminal.layer,
BunPath.layer
)
return layers
}).pipe(
Logger.withMinimumLogLevel(LogLevel.Debug),
Effect.scoped,
Layer.unwrapEffect,
Layer.provide(Layer.setConfigProvider(input?.baseConfigProvider ?? ConfigProvider.fromMap(new Map([]))))
)
npx skills add mepuka/effect-testing-mocking下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer