Skip to content

how to use moxios to return streams that have images #80

Open
@knihit

Description

@knihit

I am trying to use moxios to mock the following scenario.

axios.default.get(imageUrl, { responseType: 'stream' })

To unit test the above, I am trying to write jest with the following.

    moxios.stubRequest('http://abc.com/text.jpg', {
        status: 200,
        response: { data: fs.createReadStream(`${__dirname}/text.png`) }
    });

But the response.data. When I use response.data.pipe(somewriteablestream) it does not work.

Any help appreciated for mocking a get request returning a stream object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions