Closed johnsonsamuel closed 4 years ago
The answer is no. Mockfs cannot do it.
First, exec or spawn creates new OS process which is isolated from current nodejs process. Even if you do exec("node some.js")
to create another nodejs process, the new process is not affected by mockfs on current process.
Furthermore, ls
uses libc to access file system, it's irrelevant to mockfs which only mocks nodejs's fs module.
Thank you @3cp for your detailed explanation. I was able to mock exec
using sinon
. I was able to use mock-fs
as well.
What is this about?
Mock node's child process
exec
orspawn
?Just wanted to check if there is a possibility of mocking node process.
My question is, will the exec work and list the content from the mock fs?
which is
test.txt
?