Skip to content

Commit

Permalink
Add the jest-plugin-fs/mock export for usage within jest
Browse files Browse the repository at this point in the history
  • Loading branch information
negativetwelve committed Sep 22, 2017
1 parent a1ce023 commit 1283d88
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/jest-plugin-fs/mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('memfs').fs;
1 change: 1 addition & 0 deletions packages/jest-plugin-fs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"main": "build/fs",
"files": [
"build",
"mock.js",
"setup.js"
],
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/jest-plugin-fs/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
* test files.
*/
global.fs = require('./').default;
global.fs.inject();
5 changes: 3 additions & 2 deletions packages/jest-plugin-fs/src/__tests__/fs.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// Modules
import '../../setup';
import fsExtra from 'fs-extra';
import set from 'jest-plugin-set';
import context from 'jest-plugin-context';
import fsExtra from 'fs-extra';
import fs from '../fs';

// Install the mock for the filesystem.
jest.mock('fs', () => require('jest-plugin-fs/mock'));

/* eslint-disable no-undef */
describe('fs', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/jest-plugin-fs/src/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import memfs from 'memfs';


const fs = {
inject: () => jest.mock('fs', () => require('memfs').fs),
mock: (filesystem = {}) => memfs.vol.fromJSON(filesystem, '/'),
read: () => memfs.vol.toJSON(),
restore: () => memfs.vol.reset(),
Expand Down

0 comments on commit 1283d88

Please sign in to comment.