@zzzzbov/test-dir
v0.0.1
Published
![live-updating npm version badge][npm-version]
Downloads
2
Readme
test-dir
testDir
is a filesystem unit testing utility to create a new subdirectory of the operating system's temp directory with a randomly generated file name.
Installation
$ npm install @zzzzbov/test-dir --save-dev
Quick Start
Create the test directory before running tests, and remove it after tests have completed.
let tmp;
beforeEach(async () => {
tmp = await testDir({ chdir: true });
});
afterEach(async () => {
await tmp.remove();
});
Use the path
property to access the path to the newly created directory.
it(`should create a file`, async () => {
const filePath = path.join(tmp.path, "file.txt");
await createFile(filePath);
assert.ok(existsSync(filePath));
});