Fake node.js file system for testing. Supports
rename and their sync counterparts.
var Fs =var fs =
Define a dir
fsdir'a/b/c'fsshouldbetruefsshouldbetrue // note that it works like mkdir -pfsshouldbetrue // in fact you defined an item at absolute pathfsshouldbetrue
Dir with some meta
fsdir'bin'mtime: 100 // by default it will be set to (new Date)atime: 300ctime: 50fsshouldhave
Define an empty file
fsfsshouldfsshouldbetrue // foo automatically created
Define a file with content
fs // utf8 assumedfsfs
Define a file with arbitrary attributes
Sometimes you may want to define several items at one location. The
returns a proxy which prefixes everything you defined with
It also has convenience methods for patching-unpatching of global
Methods of new fs object are not bound to the instance. That means
var fs =var exists = fsexistsSync
doesn't work. You can use
.bind() if that's a problem.
var fs =var exists = fsexistsSync// now everything is ok
npm install fake-fs
To run tests use
npm test command.
npm installnpm test
(The MIT License)
Copyright (c) 2012 Eldar Gabdullin firstname.lastname@example.org
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.