Releases: berniegp/mock-xmlhttprequest
Releases · berniegp/mock-xmlhttprequest
v8.3.0
v8.2.0
v8.1.0
New features
- Update to
XMLHttpRequest
version "15 August 2022". - Added support for automatic progress events in
MockXhrServer
via theprogressRate
field. - The
MockXhrServer
now automatically sets theContent-Length
response header forobject
request handlers. setResponseBody()
now automatically sets theContent-Length
response header ifsetResponseHeaders()
was not called.
Bug fixes
- Added missing validation in
open()
that throws an exception if themethod
argument is not a method. - Distinguish between when the
async
argument is omitted and when it'sundefined
inopen()
. - On a
readystatechange
event, the listener list was not cloned prior to calling the event listeners. - Added missing header name and value validation in
setRequestHeader()
. - Added the
Content-Type
request header when the request body is aFormData
. - Don't discard empty header values given to
setRequestHeader()
.
v8.0.1
v8.0.0
Breaking changes
- Added the
MockXhrRequest
class to isolate each call tosend()
and respond to requests (#30). - Added Node.js package entry points. This is the
exports
field of package.json. - Changed the call order of callbacks when multiple callbacks exist for the same lifecycle hook.
setRequestTimeout()
now throws iftimeout === 0
.MockXhrServer.getRequestLog()
now returns an array copy.MockXhr.requestHeaders
now returns a copy of the request headers.- Several properties of classes that were meant to be read-only are now protected by getters.
- Deprecated
MockXhrServer.xhrMock
. UseMockXhrServer.MockXhr
instead.
New features
- Documentation overhaul.
- Migrated to TypeScript.
- More accurate typings.
- Type safety caught a few bugs.
- Added
'timeout'
and'error'
as declarative request handlers for theMockXhrServer
. - Use
Promise.resolve()
instead ofsetTimeout()
to call theonSend
hook (#29). - Added
MockXhr.getResponseHeadersHash()
. - Removed noop setters from readOnly attributes.
- Updated devDependencies.
Bug fixes
- Fixed incorrect usage of
Blob
when calculating the request's body size (#31). - Fixed bug where event handler properties (e.g.
onload
) were not called in the right order. - Fixed bug where event listener object callbacks did not receive the
event
as an argument. - Fixed bug where an event listener was called despite being removed by a previous event listener for the same event.