Skip to content

How do I mock a binary response? #1669

Answered by drazisil
drazisil asked this question in Q&A
Discussion options

You must be logged in to vote

I was close. The correct response is new Response(Buffer.from(JSON.stringify(mockManifest)))

Full code:

mockClient.intercept({
  method: 'GET',
  path: '/v2/exampleOrgName/exampleImageName/blobs/abc123',
}).reply(200, new Response(Buffer.from(JSON.stringify(mockManifest))), {
  headers: {'content-type': 'application/octet-stream'},
});

Replies: 1 comment

Comment options

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