testing/mock_fs.ts

In-memory file system mock for tests that use dependency-injected read_file and write_file callbacks. Avoids module-level mocking.

Declarations
#

2 declarations

view source

create_mock_fs
#

testing/mock_fs.ts view source

(initial_files?: Record<string, string>): MockFs

Creates an in-memory file system for tests.

read_file throws an ENOENT-tagged error for missing paths so callers can exercise the same "file doesn't exist" code path as node:fs.

initial_files

type Record<string, string>
default {}

returns

MockFs

MockFs
#

testing/mock_fs.ts view source

MockFs

In-memory file system mock for tests that use dependency-injected read_file and write_file callbacks. Avoids module-level mocking.

read_file

type (path: string, encoding: string) => Promise<string>

write_file

type (path: string, content: string, encoding: string) => Promise<void>

get_file

type (path: string) => string | undefined