API reference@evolu/commonFs › testCreateFs

function testCreateFs(overrides?: Partial<Fs>): Fs;

Defined in: packages/common/src/Fs.ts:470

Creates a test Fs with the supplied operation overrides.

Unconfigured operations throw a defect naming the method when their Task runs. Constructing a Task does not execute it. This helper performs no file system I/O; overrides provide the behavior needed by each test.

Example

import {
  assertEqual,
  assertOk,
  ok,
  testCreateFs,
  testCreateRun,
  type FsDep,
  type FsError,
  type Task,
} from "@evolu/common";

const saveMessage: Task<void, FsError, FsDep> = (run) =>
  run(run.deps.fs.writeFile("message.txt", "hello"));

await using run = testCreateRun({
  fs: testCreateFs({
    writeFile: (path, data) => () => {
      assertEqual(path, "message.txt");
      assertEqual(data, "hello");
      return ok();
    },
  }),
});

assertOk(await run(saveMessage));