Comments (18)
I'll write a failing test and then look at this. It's not a feature I've explored much
from fetch-mock.
I've added a test #95 which passes in node 5. I notice you have sendAsJSON
in your code when it should be sendAsJson
. I've managed to get it to pass in node 5 and 6
from fetch-mock.
Good point regarding the key name, but this issue is about ArrayBuffer, not Buffer.
from fetch-mock.
Ah, and it turns out I wrote the issue incorrectly - the actual code I wrote uses sendAsJson
.
from fetch-mock.
I suggest raising this as an issue on node-fetch, which this library uses to construct responses. It already supports use cases that go beyond the fetch spec, so they could be keen to add support for ArrayBuffer
from fetch-mock.
What does this have to do with the fetch spec? The fetch spec already supports ArrayBuffer on the response https://developer.mozilla.org/en-US/docs/Web/API/Body/arrayBuffer
from fetch-mock.
I assumed you were running the tests in node (as opposed to in a browser) as the error stack looks more like something generated in node. If this is the case then support for arrayBuffer needs to be added to node-fetch. node-fetch/node-fetch#51. Not everything defined in the fetch spec is implemented, or is even intended to be implemented (https://github.com/bitinn/node-fetch/blob/master/LIMITS.md), in node-fetch, but for most use cases it's similar enough.
from fetch-mock.
What does this have to do with node-fetch? The error stack is entirely within fetch-mock.
from fetch-mock.
Ah I missed that sorry. I now have a failing test and will work on fixing it
from fetch-mock.
Great! Any luck?
from fetch-mock.
I have a failing test, but I'm still looking into what the behaviour should be with regard to building a Body from binary data. The spec https://fetch.spec.whatwg.org/#bodies mentions that ReadableStream may change to be ReadableByteStream, which may have some bearing on it.
Other than that I need to update fetch-mock to use stream.pipe() and add a check body isn't an ArrayBuffer before trying to 'utf8' decode, which may be enough
from fetch-mock.
This might become a ReadableByteStream object. While the type might change, the behavior specified will be equivalent since the hypothetical ReadableByteStream object will have the same members as the ReadableStream object has today.
What bearing would that have on the behaviour? Can you share your failing test? I'd like to help you get this over the finish.
from fetch-mock.
here you go https://github.com/wheresrhys/fetch-mock/compare/rhys/buffer
from fetch-mock.
FWIW it seems that this mostly works in the browser already (as opposed to NodeJS), but there's still some weirdness in webkit as seen in https://github.com/cockroachdb/cockroach/pull/7178/files - still not quite sure what's going on there.
from fetch-mock.
closing due to incativity
from fetch-mock.
Sorry, this was JakeChampion/fetch#351.
from fetch-mock.
was this implemented update fetch-mock to use stream.pipe()
?
from fetch-mock.
@qjflores Please open a new issue if something is missing for you. I have very little memory of what this discussion was about
from fetch-mock.
Related Issues (20)
- Remove support for passing in a `matcher` property in
- migrate docs to docusaurus
- Add support for all the types of body in the fetch spec
- Remove top level done and flush methods
- Rename functionMatcher to func
- Export types perfectly from @fetch-mock/core
- Cannot consume CJS build with TypeScript HOT 7
- Combine callLog and normalizedRequest?
- access to query parameters in CallLog
- host: and protocol: url matchers
- Implement spec compliant errors HOT 2
- Export more types from @fetch-mock/core HOT 8
- Rethink URL normalization behaviour HOT 1
- Types broken in 10.x for ESM HOT 7
- `.../es5/client-bundle.js` no longer exist HOT 9
- `globrex` does not support browser HOT 5
- browser tests aren't actually running in a browser any more
- @fetch-mock/vitest todo HOT 1
- fetch-mock -> @fetch-mock/core codemod
- Process is not defined HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fetch-mock.