Hyperlinkv0.8.0-beta.28

FileSystem

FileSystem.layerNoopconsteffect/FileSystem.ts:1040
(fileSystem: Partial<FileSystem>): Layer.Layer<FileSystem>

Creates a Layer that provides a no-op FileSystem implementation for testing.

Details

This is a convenience function that wraps makeNoop in a Layer, making it easy to provide the test filesystem to your Effect programs.

Example (Providing a no-op FileSystem layer)

import { Effect, FileSystem } from "effect"

// Create a test layer with specific behaviors
const testLayer = FileSystem.layerNoop({
  readFileString: (path) => Effect.succeed("mocked content"),
  exists: () => Effect.succeed(true)
})

const program = Effect.gen(function*() {
  const fs = yield* FileSystem.FileSystem
  const content = yield* fs.readFileString("any-file.txt")
  return content
})

// Provide the test layer
const testProgram = Effect.provide(program, testLayer)
layers
export const layerNoop = (fileSystem: Partial<FileSystem>): Layer.Layer<FileSystem> =>
  Layer.succeed(FileSystem)(makeNoop(fileSystem))