How to use the mock-fs.restore 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 Tatamo / atcoder-cli / tests / __tests__ / template.ts View on Github external
mock({
				[DUMMY_CONFIG_DIRECTORY_PATH]: {
					...templates2files(mock_templates),
					// add directory without template.json
					"non-template": {
						"this-is-not-template.json": JSON.stringify({
							task: {
								submit: "main.cpp",
								program: ["main.cpp"]
							}
						})
					}
				}
			});
			const result = await template.getTemplates();
			mock.restore();
			// there's no template "non-template"
			expect(result).toMatchSnapshot();
		});
		test("files to be ignored", async () => {
github ShailenNaidoo / hydrogen / __tests__ / helpers / checkIfBuildFolderExists.spec.ts View on Github external
test('should return false if build folder exists', async () => {
    mock({ 'dist': { 'index.html': 'Fake content' }});
    const exists = await checkIfBuildFolderExists();

    expect(exists).toBe(false);
    mock.restore();
  });
github ShailenNaidoo / hydrogen / __tests__ / helpers / checkIfLayoutAndPagesDirectoriesExist.spec.ts View on Github external
test('should be false if directories do exist', async () => {
    mock(fsConfig, { createCwd: false, createTmp: false });

    const [check] = await checkIfLayoutAndPageDirectoriesExist();

    expect(check).toBe(false);

    mock.restore();
  });
github adogor / npm-autolink / test / support / utils.js View on Github external
export function restoreFs() {
  mockFs.restore();
}
github liady / webpack-node-externals / test / test-utils.js View on Github external
exports.restoreMock = function restoreMock(){
    mockDir.restore();
}
github sonatype-nexus-community / auditjs / src / Config / IqServerConfig.spec.ts View on Github external
it("should return true when it is able to save a config file", async () => {
    sinon.stub(os, 'homedir').returns('/nonsense');
    mock({ '/nonsense': {}});

    let config = new IqServerConfig("username", "password", "http://localhost:8070");
    let configPersist = new ConfigPersist("username", "password", "http://localhost:8070")
    expect(config.saveFile(configPersist)).to.equal(true);

    let conf = config.getConfigFromFile('/nonsense/.iqserver/.iq-server-config');

    expect(conf.getUsername()).to.equal('username');
    expect(conf.getToken()).to.equal('password');
    expect(conf.getHost()).to.equal('http://localhost:8070');
    mock.restore();
    sinon.restore();
  });
});
github sonatype-nexus-community / auditjs / src / Config / OssIndexServerConfig.spec.ts View on Github external
it("should return true when it is able to save a config file", async () => {
    sinon.stub(os, 'homedir').returns('/nonsense');
    mock({ '/nonsense': {}});

    let config = new OssIndexServerConfig("username", "password");
    let configPersist = new ConfigPersist("username", "password")
    expect(config.saveFile(configPersist)).to.equal(true);

    let conf = config.getConfigFromFile('/nonsense/.ossindex/.oss-index-config');

    expect(conf.getUsername()).to.equal('username');
    expect(conf.getToken()).to.equal('password');
    mock.restore();
    sinon.restore();
  });
});
github dtysky / MoeNotes / spec / utils.spec.js View on Github external
it("Get files", () => {
        mock({
            dir1: {
                d1: {},
                "f1.md": "file",
                f2: "file"
            },
            dir2: {}
        });
        expect(
            arrayAreEqual(getFiles("dir1"), ["f1"])
        ).toBeTruthy();
        expect(
            arrayAreEqual(getFiles("dir2"), [])
        ).toBeTruthy();
        mock.restore();
    });

mock-fs

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

MIT
Latest version published 8 days ago

Package Health Score

80 / 100
Full package analysis