# @gustavnikolaj/mock-mock-fs

> Example with mocha as a test runner.

Latest version **1.0.1** (published 2019-03-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install @gustavnikolaj/mock-mock-fs
pnpm add @gustavnikolaj/mock-mock-fs
yarn add @gustavnikolaj/mock-mock-fs
bun add @gustavnikolaj/mock-mock-fs
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-03-11 |
| First published | 2019-03-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | gustavnikolaj |

## Links

- npm: https://www.npmjs.com/package/@gustavnikolaj/mock-mock-fs
- npm.io page: https://npm.io/package/@gustavnikolaj/mock-mock-fs

## Recent versions

- 1.0.1 (latest) — 2019-03-11
- 1.0.0 — 2019-03-11

## README

# mock-mock-fs

Example with mocha as a test runner.

```js
// convert-file-to-upper-case.js
const fs = require("fs");

function convertFileToUpperCase(path) {
  const content = fs.readFileSync(path, "utf-8");
  fs.writeFileSync(content.toUpperCase(), "utf-8");
}

// convert-file-to-upper-case.spec.js
const rimraf = require("rimraf");
const expect = require("unexpected");
const path = require("path");
const fs = require("fs");

const testFolderPath = path.resolve(__dirname, "__test-tmp__");

describe("convertFileToUpperCase", () => {
  beforeEach(() => {
    // mockMockFs does not clean up itself, so we are rimraffing the folder
    // between invocations.
    rimraf.sync(testFolderPath);
  });

  it("should convert a files text content to upper case", () => {
    mockMockFs(
      {
        "foo.txt": "foobar"
      },
      testFolderPath
    );

    const testFilePath = path.resolve(testFolderPath, "foo.txt");

    convertFileToUpperCase(testFilePath);

    expect(fs.readFileSync(testFilePath, "utf-8"), "to equal", "FOOBAR");
  });
});
```

---
_Source: https://npm.io/package/@gustavnikolaj/mock-mock-fs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
