fs-fixture is a JavaScript/TypeScript library designed to simplify the creation and management of temporary file system fixtures for testing purposes. Currently at version 2.13.0, the library is under active development with frequent minor and patch releases, indicating a robust and responsive maintenance schedule. Key differentiators include its extremely small footprint (1.1 kB gzipped) with no external dependencies, a simple object-based API for defining file structures, automatic resource cleanup via TypeScript 5.2+ `using` keyword, and built-in support for JSON serialization/deserialization. It inherits `fs/promises` type signatures for file operations, ensuring strong type safety and familiar API patterns. The library also supports advanced features like symlinks, binary file handling with Buffers, and a pluggable filesystem interface for custom `fs/promises`-compatible implementations.
npm install fs-fixtureVerified import paths — ran on the pinned version, not inferred.
Demonstrates creating a file system fixture with nested files, reading a file's content, writing a JSON file, and explicitly cleaning up the temporary directory.
Always use `await fixture.rm()` in a `finally` block or utilize the `await using fixture = ...` syntax (requires TypeScript 5.2+ and compatible runtime) for automatic disposal.
Ensure your project's Node.js runtime is version 18 or higher. Update `nvm use 18` or adjust CI/CD configurations accordingly.
Upgrade TypeScript to 5.2 or later. If using Node.js, ensure you're running a version with stable ERM support, or explicitly call `await fixture.rm()` instead.
When using a custom `fs` option, always define your fixture structure using a `FileTree` object instead of a string path to an existing directory.
Ensure your project uses ES modules (`"type": "module"` in `package.json`) and import `createFixture` using `import { createFixture } from 'fs-fixture'`.Upgrade your TypeScript version to 5.2 or newer. If in Node.js, ensure your Node.js version supports ERM or fall back to explicitly calling `await fixture.rm()`.
Verify that the path you are trying to access (`e.g., fixture.readFile('non-existent.txt')`) corresponds exactly to a file or directory specified in your `createFixture` object or template. Use `await fixture.exists('path')` to check for its presence.No dependency data recorded yet.