Skip to content

Mocking Readable Streams #2365

Answered by kettanaito
bliu13 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi.

This likely has to do with the package you are using to create a stream. This part, for example, makes little sense to me:

await workbook.xlsx.write(stream)

You normally don't await writes/stream because that defies the entire purpose of a pending stream where data is being written to continuously.

MSW supports ReadableStream, so if something is amiss I recommend boil it down to using plain PassThrough() and pushing data there, then advance the complexity until you reach the breaking point.

I also don't see you using Web Streams at all in your examples. You use node:stream, which is not the same. You have to convert Readable to ReadableStream before you pass it to MSW. To do that, use n…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kettanaito
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants