[–] colinbartlett 12y ago ↗ Can someone give me an example of why I'd want this? [–] snowmantw 12y ago ↗ 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. [–] lgierth 12y ago ↗ There is a similar library for Ruby, called FakeFS [1], and it has better explanation and examples for the problems with testing the file system.[1] https://github.com/defunkt/fakefs [–] andypants 12y ago ↗ 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 testsIt's annoying to fill the content of dummy files with file APIsForgot to delete files after test may cause some troublesTests should completely live within sandbox. Create files and directories may cause side-effects on your systemIf 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 testsSo I create this to implement a filesystem in process memory, and a mocked fs module which has some compatible APIs.
[–] snowmantw 12y ago ↗ 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.
[–] lgierth 12y ago ↗ There is a similar library for Ruby, called FakeFS [1], and it has better explanation and examples for the problems with testing the file system.[1] https://github.com/defunkt/fakefs
[–] andypants 12y ago ↗ 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 testsIt's annoying to fill the content of dummy files with file APIsForgot to delete files after test may cause some troublesTests should completely live within sandbox. Create files and directories may cause side-effects on your systemIf 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 testsSo I create this to implement a filesystem in process memory, and a mocked fs module which has some compatible APIs.
5 comments
[ 2.7 ms ] story [ 24.1 ms ] thread[1] https://github.com/defunkt/fakefs
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.