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
New text does not get appended to a file in a mock-fs filesystem when the write() function of a writable stream created using the following code is called:
The following snippet of code (originally part of a Jest test script) can be used to reproduce this bug:
constfs=require("fs");const{ test, expect }=require("@jest/globals");constmock=require("mock-fs");functioncleanUp(){mock.restore();}test("Append to a file in a 'mock-fs' filesystem",async()=>{mock({"test.log": "[Block 1]"});lettestLogFileWriteStream=fs.createWriteStream("test.log",{flags: "a"});testLogFileWriteStream.write("[Block 2]");lettextInTestLogFile=awaitfs.promises.readFile("test.log",{encoding: "utf-8"});try{expect(textInTestLogFile).toEqual("[Block 1][Block 2]");// Here, the 'test.log' file contains its initial text (i.e. '[Block 1]') but does not contain the text appended to it (i.e. '[Block 2]') causing this assertion to fail.}finally{cleanUp();}});
Is there a way to resolve this bug?
The text was updated successfully, but these errors were encountered:
One difference is that the added test calls end on the write stream. Another difference is that it doesn't use Jest. Does your test pass if you call end on the write stream?
New text does not get appended to a file in a
mock-fs
filesystem when thewrite()
function of a writable stream created using the following code is called:The following snippet of code (originally part of a Jest test script) can be used to reproduce this bug:
Is there a way to resolve this bug?
The text was updated successfully, but these errors were encountered: