# test-with-data-folder

> Utility to handle tests involving test data folders.

Latest version **0.0.10** (published 2021-07-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install test-with-data-folder
pnpm add test-with-data-folder
yarn add test-with-data-folder
bun add test-with-data-folder
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.10 |
| Published | 2021-07-28 |
| First published | 2021-06-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Alan Bergin |
| Maintainers | folkforms |

## Links

- npm: https://www.npmjs.com/package/test-with-data-folder
- Repository: https://github.com/folkforms/test-with-data-folder
- Homepage: https://github.com/folkforms/test-with-data-folder#readme
- Issues: https://github.com/folkforms/test-with-data-folder/issues
- npm.io page: https://npm.io/package/test-with-data-folder

## Dependencies (2)

- [shelljs](https://npm.io/package/shelljs.md) ^0.8.4
- [@folkforms/file-io](https://npm.io/package/@folkforms/file-io.md) ^0.2.2

## Recent versions

- 0.0.10 (latest) — 2021-07-28
- 0.0.9 — 2021-07-20
- 0.0.8 — 2021-07-16
- 0.0.7 — 2021-07-14
- 0.0.6 — 2021-07-08
- 0.0.5 — 2021-07-08
- 0.0.4 — 2021-06-29
- 0.0.3 — 2021-06-29
- 0.0.2 — 2021-06-29
- 0.0.1 — 2021-06-29

## README

# test-with-data-folder

Take a test data folder and automatically copy, modify, compare against expected data, and remove.

## Example

    const testWithDataFolder = require("test-with-data-folder");
    const { testCase1Func } = require("./test-case-1/testCase1Func"); // Function under test

    test('test case 1', () => {
      // Define paths
      const inputFolder = "./tests/test-case-1/input";
      const expectedFolder = "./tests/test-case-1/expected";
      const temporaryFolder = "./tests/test-case-1/temp";

      // Define the function under test
      const testFunction = () => { testCase1Func(temporaryFolder); };

      // Run the test
      testWithDataFolder(testFunction, inputFolder, expectedFolder, temporaryFolder);
    });

The `testWithDataFolder` method will:

1. Delete `temporaryFolder`
2. Copy `inputFolder` to `temporaryFolder`
3. Run `testFunction()`
4. Compare `temporaryFolder` against `expectedFolder`
5. Delete `temporaryFolder`

---
_Source: https://npm.io/package/test-with-data-folder · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
