0.0.1 • Published 2 years ago

@zzzzbov/test-dir v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

test-dir

live-updating npm version badge

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));
});

See API for details