On MacOS, with the real fs where file test-data/bob.txt exists, the following rename fails :
> fs.renameSync('test-data/bob.txt', 'test-data/pete/');
Error: ENOENT: no such file or directory, rename 'test-data/bob.txt' -> 'test-data/pete/'
at Object.fs.renameSync (fs.js:766:18)
at repl:1:4
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at REPLServer.defaultEval (repl.js:240:29)
at bound (domain.js:301:14)
at REPLServer.runBound [as eval] (domain.js:314:12)
at REPLServer.onLine (repl.js:441:10)
at emitOne (events.js:121:20)
at REPLServer.emit (events.js:211:7)
at REPLServer.Interface._onLine (readline.js:282:10)
But with mock-fs, it succeeds:
> let mockfs = require('mock-fs')
undefined
> mockfs({ 'test-data': { 'bob.txt': 'a text file' } })
undefined
> fs.renameSync('test-data/bob.txt', 'test-data/pete/');
undefined
> fs.readdirSync('test-data');
[ 'pete' ]
Thank you.
(On Windows, mock-fs is consistent with fs -- the rename would succeed with both.)
On MacOS, with the real
fs
where filetest-data/bob.txt
exists, the following rename fails :But with
mock-fs
, it succeeds:Thank you.
(On Windows,
mock-fs
is consistent withfs
-- the rename would succeed with both.)