How to use the mock-fs.directory function in mock-fs

To help you get started, we’ve selected a few mock-fs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holography / holograph / test / err.js View on Github external
describe("Holograph", function() {
    mock({
        'holograph': mock.directory({
            mode: '0700',
            uid: 1,
            gid: 1,
            items: {
                'index.html': "Hello, world!"
            }
        })
    });

    describe("Setup", function() {
        it("errs when the build destination cannot be removed", function(done) {
            h.holograph({ destination: "./holograph" }, function(err) {
                expect(err).to.be.an('error');
                expect(err.message).to.have.string('EACCES');
                done();
            });
github ewnd9 / media-center / test / find-files-spec.js View on Github external
function mockFs() {
  mock({
    [testDir]: {
      [showFolder]: mock.directory({
        birthtime: pastDate,
        items: {
          [showFile1]: f(pastDate),
          [showFile2]: f(pastDate),
          [showFile3]: f(pastDate),
          [showFile4]: f(pastDate)
        }
      }),
      [movieFolder]: mock.directory({
        birthtime: nearestDate,
        items: {
          [movieFile]: f(nearestDate)
        }
      })
    }
  });
}
github elastic / kibana / src / server / keystore / __tests__ / keystore.js View on Github external
beforeEach(() => {
    mockFs({
      '/data': {
        'protected.keystore': protoctedKeystoreData,
        'unprotected.keystore': unprotectedKeystoreData,
      },
      '/inaccessible': mockFs.directory({
        mode: '0000',
      })
    });
  });
github TypeStrong / fork-ts-checker-webpack-plugin / test / unit / CancellationToken.spec.js View on Github external
beforeEach(() => {
    var fsTree = {};
    fsTree[os.tmpdir()] = mockFs.directory();

    mockFs(fsTree);
  });
github jan-molak / serenity-js / packages / core / spec / io / file_system.spec.ts View on Github external
it ('complains when provided with an a path to a file that can\'t be overwritten', () => {
            mockfs({ '/sys': mockfs.directory({
                mode: 400,
                items: {
                    'file.json': mockfs.file({
                        mode: 400,
                        content: '',
                    }),
                },
            })});

            const out = new FileSystem('/sys');
            const path = isWinOS() ? '\\\\?\\C:\\sys\\file.json' : '/sys/file.json';

            return expect(out.store('file.json', JSON.stringify(originalJSON)))
                .to.be.eventually.rejectedWith(`EACCES, permission denied \'${path}\'`);
        });
    });
github jan-molak / serenity-js / spec / api / serenity / io / file_system.spec.ts View on Github external
it ('complains when provided with an a path to a file that can\'t be overwritten', () => {
            mockfs({ '/sys': mockfs.directory({
                mode: 400,
                items: {
                    'file.json': mockfs.file({
                        mode: 400,
                        content: '',
                    }),
                },
            })});

            let out = new FileSystem('/sys');

            return expect(out.store('file.json', JSON.stringify(originalJSON)))
                .to.be.eventually.rejectedWith('EACCES, permission denied \'/sys/file.json\'');
        });
    });

mock-fs

A configurable mock file system. You know, for testing.

MIT
Latest version published 1 year ago

Package Health Score

68 / 100
Full package analysis