I'm attempt to stub the fs.writeFileSync method, but it's causing a Reference Error.
In that case, oeverloading the fs method causes troubes as sinon.restore() doesn't work. *My stub.* const writeImageStub = sinon.stub(fs, 'writeFileSync') .callsFake((file, data, (err) => { expect(file).to.be.a('string') expect(getFileExtension(data)).to.equal('jpg') expect(new Buffer.alloc(data)).to.be.a('object') return '/static/images/image.jpg' })) *Reference error*: file is not defined. How to do this, what causing this and exist other method? *PS:* Spying the method causes the write operation to be executed, on this case i have to delete the files written, but how to get the filename as the format is *filename.Date.now.extension*. Don't exist a way to store as a global variable to do this. -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/3d26db31-2c2c-4c3b-8055-7c8f54628bf6%40googlegroups.com.