Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow buffers as mock response data #1086

Merged
merged 2 commits into from
Nov 7, 2021

Conversation

runeh
Copy link
Contributor

@runeh runeh commented Nov 5, 2021

With this change, it's possible to return binary payloads from an intercepted call:

const mockImage = readFileSync('/path/to/image/png')
mockPool.intercept({ path: '/foo', method: 'GET' }).reply(200, mockImage)

I haven't bothered with docs yet. I'll update them if there's interest in merging this.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, could you add it to the docs?

@runeh
Copy link
Contributor Author

runeh commented Nov 7, 2021

I added some docs. Turned out to be very little, but I think it covers the change reasonably well.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ronag ronag merged commit 98416bf into nodejs:main Nov 7, 2021
KhafraDev pushed a commit to KhafraDev/undici that referenced this pull request Jun 23, 2022
* feat: Allow buffers as mock response data

* Update docs
crysmags pushed a commit to crysmags/undici that referenced this pull request Feb 27, 2024
* feat: Allow buffers as mock response data

* Update docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants