- Avoid errors in
fs.existsSync
(see #401)
- Use setImmediate instead of process.nextTick (thanks @regseb, see #360)
Dependency Updates
- bump chai from 4.3.4 to 4.5.0
- bump eslint from 8.21.0 to 8.57.1
- Remove conditions for untested versions
- Remove disabled tests for mock.fs (thanks @everett1992, see #391)
- Fix tests on node 20 (thanks @everett1992, see #387)
- Fix timeout in failing test (thanks @everett1992, see #390)
- Stop testing on Node 12 and 14
Dependency Updates
- chore(deps-dev): bump rimraf from 3.0.2 to 6.0.1
- chore(deps): bump actions/checkout from 2 to 4
- chore(deps-dev): bump mocha from 9.2.2 to 10.7.3
- chore(deps-dev): bump braces from 3.0.2 to 3.0.3
- chore(deps-dev): bump word-wrap from 1.2.3 to 1.2.4
- chore(deps): bump json5 from 1.0.1 to 1.0.2
- Fix EACCES error on access by root user (thanks @danielkatz, see #369)
- Fix bug on utimes and futimes; add support of lutimes (thanks @3cp, see #366)
- Fix for BigInt stats in Node 16.7 (thanks @ahippler, see #363)
- Fix for BigInt stats in Node 18.7 (thanks @3cp, see #361)
- Avoid open
FSREQCALLBACK
file handles (thanks @jloleysens, see #342)
- Added
engines
topackage.json
to clarify that Node >= 12 is required (thanks @tillig, see #337)
- Added support for Node >= 16.3 (thanks @Rugvip, see #335)
Breaking change:
- Remove support for Node < 12. If you want to use mock-fs to test on Node 10 or lower, stick with mock-fs@4.
New features:
- Support for BigInt file stats - required for Node 15+ (thanks @3cp, see #325)
- Attempt to fix logging when using
mock-fs
withtape
(see #322) - Minor fix for
bypass()
(thanks @3cp, see #320)
- Make
process.chdir()
,process.cwd()
, andfs.createWriteStream()
work withbypass()
(thanks @3cp, see #307) - Fix memory leak associated with Node 10 (thanks @3cp, see #303)
- Async function handling in
bypass()
(see #306) - Big new feature! Temporarily bypass the mocked filesystem with the
bypass()
function (thanks @nonara, see #304)
- Check permissions in
readdir
andreaddirSync
(thanks @warpdesign, see #295) - Add support for
Buffer
arg on manyfs
functions (thanks @3cp, see #293) - Fix checks for read permission (thanks @3cp, see #289)
- Correct error code for
readFile
on a directory (thanks @3cp, see #286)
- Support
withFileTypes
when reading directories (thanks @mrmlnc, see #287)
- Throw ENOTDIR when trying to open an incorrect path (thanks @niieani, see #282)
- Fix maybeCallback return (thanks @3cp, see #281)
- Fix bad promise rejection on some fs.promises methods (thanks @3cp, see #279)
- Fix timestamps for Node > 12.10 (thanks @3cp, see #277)
- Fix for
fs.mkdir
with therecursive
option on existing directories (thanks @3cp, see #271)
- Support the
recursive
option forfs.mkdir
(thanks @3cp, see #268)
- Improve
readFile
support for Node 10+ (thanks @huochunpeng, see #265) - Updated dev dependencies (see #267)
- Fix compatibility issues with Node 10 and 11 (thanks @huochunpeng #260)
- Support experimental
fs.promises
(thanks @huochunpeng #260)
- Fix for readdir on Node 10.10 (thanks @maxwellgerber #251)
- Fix for reading and writing using Uint8Array (thanks @maxwellgerber #249)
- Document how to properly restore the fs with Jest snapshot testing (thanks @tricoder42 #247)
- More informative error when opening a directory (thanks @maxwellgerber #242)
Note that the mocked fs.createReadStream and fs.createWriteStream are not working properly with Node 10.5+.
- Implement binding.copyFile (#243)
- Stat fixes for Node 10.5 (thanks @tomhughes, see [#241][#241])
- Updates for Node 10 compatibility (#237)
- Throw ENOENT in readlink when item is missing (thanks @deployable, see #232)
- Add path to errors when it exists (thanks @deployable, see #230)
- Throw if item content is invalid in config (thanks @mutantcornholio, see #221)
- Use const in readme (thanks @denar90, see #222)
- Document that tests are run on Node 8.x as well.
- Add support for fs.mkdtemp() and fs.mkdtempSync (see #207)
- Update fs.stat(), fs.lstat(), and fs.fstat() for Node 7.7+ (thanks @not-an-aardvark, see #198)
- Correctly follow a symlink chain in
binding.open()
(thanks @vlindhol, see #195)
In earlier versions of mock-fs
, a monkey-patched version of the fs
module was used to provide an in-memory filesystem. With each major release of Node, the mock-fs
package needed to include a modified copy of the fs
module. With the mock-fs@4
release, this package no longer includes a modified copy of the fs
module. Instead, this package overrides process.binding('fs')
. While this is not part of Node's stable API, it has proven to be a more stable interface than the fs
module itself (based on experience implementing it with Node 0.8 through 7.0).
Upgrading from 3.x to 4.0 should be straightforward for most applications. There are several breaking changes that may be restored in future releases:
- The
mock.fs()
function has been removed. - The object created by
fs.stat()
and friends is no longer an instance offs.Stats
(though it behaves as one). - Lazy
require()
calls do not work consistently.
Detailed changes:
- Only override
process.binding('fs')
(#182) - Expose the root of the mocked filesystem (thanks @ciaranj, see #194)
- Revert the require cache clearing behavior (#181).
- Support for Node 7.x (thanks @goliney, see #174).
- Remove calls to
printDeprecation
(#175). - Break early when checking version (thanks @isiahmeadows, see #157).
- Add a note about restoring
fs
(thanks @matheuss, see #147). - Clear the require cache before overriding fs functions (#141)
- Support for Node 6.x (thanks @tmcw, see #107).
- Implement
binding.writeBuffers()
(see #94).
- Add
createCwd
andcreateTmp
options to control the creation ofprocess.cwd()
andos.tmpdir()
directories in the mocked filesystem (see #72). - Update Travis and AppVeyor configurations (see #73)
- Remove unused dev dependency (see #75)
- Support for Node 5.x (thanks @tmcw, see #69).
- Support for Node 4.x (thanks @AlexMeah, see #65).
- Traverse symlinks recursively (thanks @caitp, see #57).
- Upgrade to [email protected] (thanks @mbarlock, see #60).
- Support for io.js 3.0 (thanks @JustBlackBird, see #61).
- Follow symlinks in
readdir()
andreaddirSync()
(thanks @caitp, see #56).
- Override
process.cwd()
andprocess.chdir()
to work with mocked filesystem (thanks @timkendrick, see #41). - Add note about known incompatibilities (thanks @psalaets, see #45).
- Support for io.js 2.0 (thanks @jwilsson, see #38).
- Add
birthtime
toStats
objects (thanks @meandmycode, see #33).
- Support for io.js 1.1 (thanks @andrewblond, see #21).
- Testing on Windows with AppVeyor (thanks @andrewblond, see #22).
- Support for Node 0.12 (thanks @mlegenhausen, see #18).
- Preserve arity of callbacks (see #11).
- Fixes for Node 0.11.13 (see #9).
- Respect file mode on POSIX-compliant systems (see #7).
- Add benchmarks comparing mock-fs and fs modules (see #6).
- Added more complete license text.
- Test on Node 0.9 and 0.11 in addition to 0.8 and 0.10.
- Added this changelog.
- Removed unused gruntfile.js.
- Directory mtime is now updated when items are added, removed, or modified (#2).
- Fixed several issues on Windows (see #3). One issue remains on Windows with Node 0.8 (see #4).
- Swapped out Grunt with a single script to run tasks (see #5).
- Simplified API (see #1).