I have a function in which I use fs.createReadStream, I want to mock it so I can test, for example, that the functionTest is being called on receiving data and the functionTest2 is being called on stream's end.
The code is something like this:
const readStream = fs.createReadStream(filePath, { highWaterMark: 260 * 1000 });
readStream.on("data", (chunk) => {
functionTest();
});
readStream.on("end", (chunk) => {
functionTest2("example")
});
I have take a look inte mock-fs and memfs, but honestly Im very confused and don't know which is te correct path to follow
In order to make the function testable, I would split it in to two parts: