jest-plugin-fs
Jest plugin for mocking out the filesystem.
Getting Started
Install jest-plugin-fs
using yarn
:
yarn add --dev jest-plugin-fs
Motivation
Jest currently does not have an easy way to mock out the filesystem. This plugin aims to change that. Here's an example:
; // Mock out the filesystem.jest; ;
Usage
If you want, you can import fs
from jest-plugin-fs
at the top of every test:
; // This installs the mock for 'fs'.jest;
If you want to install fs
attached to the global jest
object, you can modify the jest
section of your package.json
to include:
"jest":
Example
Here's an example test that tests fs
itself:
// TODO