Closed CzBuCHi closed 7 years ago
not sure what going on but code bellow will create new directory in cwd: (expected behavior is that it will create temp dir in mocked fs..)
describe('pfs', function () { beforeEach(function () { mock({ 'file.txt': 'fred', 'folder': {} }); }); afterEach(function () { mock.restore(); }); // just test, that my promise wrapper calls fs.mkdtemp with correct param... it('mkdtemp(prefix: string)', function () { const spy = sinon.spy(fs, 'mkdtemp'); return pfs.mkdtemp('prefix') .then(name => { spy.restore(); sinon.assert.calledOnce(spy); const args = spy.getCall(0).args; expect(args).to.deep.equal(['prefix']); }); }); }); module pfs { export function mkdtemp(prefix: string) { return new Promise<string>((resolve, reject) => fs.mkdtemp(prefix, (err, folder) => { if(err) reject(err); else resolve(folder); }); } }
Thanks for the report @CzBuCHi. mkdtemp is missing from the mock binding. It shouldn't be too much effort to add.
mkdtemp
fs.mkdtemp() and fs.mkdtempSync() support added in mock-fs@4.3.
fs.mkdtemp()
fs.mkdtempSync()
mock-fs@4.3
not sure what going on but code bellow will create new directory in cwd: (expected behavior is that it will create temp dir in mocked fs..)