You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importfsfrom'node:fs'importpathfrom'node:path'importtestfrom'node:test'importmockfrom'mock-fs'test.beforeEach(()=>{mock({[import.meta.dirname]: {}})})test.afterEach(()=>{mock.restore()})test('Test',async(t)=>{// ❌ This will create the file in the real file systemfs.createWriteStream(path.join(import.meta.dirname,'testing-2024-11-13.001.log'))// ✅ This will not// fs.writeFileSync(path.join(import.meta.dirname, 'testing-2024-11-13.001.log'), 'hello world!')for(constfileoffs.readdirSync(import.meta.dirname)){console.log(file)}})
Just create test file mock-fs.test.mjs
And then run the test with the following command
node --test --experimental-default-type=module
The text was updated successfully, but these errors were encountered:
Just create test file
mock-fs.test.mjs
And then run the test with the following command
The text was updated successfully, but these errors were encountered: