5 comments

[ 2.7 ms ] story [ 24.1 ms ] thread
Can someone give me an example of why I'd want this?
I'm writing a building tool and need to write some file manipulation tests. Usually I need to prepare fixture files or create and remove them in test program, and this is very annoying. So I invented this to avoid to do that.
It's explained in the readme:

Sometime we just want to test some simple file handling functions, and don't want to create real files and directories because:

It's annoying to remember to remove test files and directories after tests

It's annoying to fill the content of dummy files with file APIs

Forgot to delete files after test may cause some troubles

Tests should completely live within sandbox. Create files and directories may cause side-effects on your system

If your dummy files and directories got affected by other processes on your system, you may have no chance to know what's going wrong with your tests

So I create this to implement a filesystem in process memory, and a mocked fs module which has some compatible APIs.