1.0.2 • Published 1 year ago

jest-mock-fs v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

jest-mock-fs

Github: https://github.com/tashes/jest-mock-fs

Install this package using:

npm install jest-mock-fs

This package will create a jest mock factory function to allow you to mock a filesystem while still being able to check mock calls. To use it, import it and call it like so:

const jestMockFs = require('jest-mock-fs');

var mockFs = jestMockFs({
    'folder': {
        'file.ext': "contents",
        'anotherfile.ext': new Buffer()
    },
    'file.txt': "othercontents"
});
jest.mock('fs', () => ({ ...mockFs }));

The following fs functions have been mocked till now:

  • existsSync
    • _path_
  • readFileSync
    • path
    • options
      • encoding
  • writeFileSync
    • path
    • contents
    • options
        • encoding
  • unlinkSync
    • path
  • readdirSync
    • -path
  • mkdirSync
    • path
  • rmSync
    • path
    • options
      • force
      • recursive
      • maxRetries
      • retryDelay
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago