v3.0.0
💥 Breaking changes:
- Mockttp no longer supports Node.js v12, which is now end-of-life. The new minimum version is Node v14.14.0.
 - Lots of previously deprecated APIs were removed:
- All rule definition that didn't start with 
.for[...](), such asmockServer.get(),mockServer.post()andmockServer.anyRequest()were removed. These were previously deprecated in v2.5.0. These can all be replaced with the equivalentforXmethod, e.g.mockServer.forGet(),mockServer.forPost()andmockServer.forAnyRequest(). All rule builder methods now consistently start withmockServer.forX(). - Standalone servers are now admin servers, and all previously-deprecated references to 'standalone' have been replaced with 'admin', for example 
Mockttp.getStandalone()is nowMockttp.getAdminServer(). - The admin server's (previously the standalone server's) 
activeServerPortsmethod has been removed, and themock-server-started/stoppingevents have been replaced withmock-session-started/stopping. - The deprecated 
handlersandMockRuleDataroot exports have been removed, they should be replaced withrequestHandlersandRequestRuleData. - The deprecated 
tlsClientErrormockttp instance subscription event has been removed, it should be replaced withtls-client-errorinstead. - The deprecated 
ignoreHostCertificateErrorspassthrough rule option was removed, it should be replaced with the newignoreHostHttpsErrorsinstead. - The previously deprecated 
addRulesandsetRulesmethods have been removed, they should be replaced withaddRequestRulesandsetRequestRules. - The 
setFallbackRulemethod has been removed, it should be replaced by setting rules with the newpriority: 0field instead. - The deprecated 
thenJSONrequest rule builder method has been removed, it should be replaced withthenJsoninstead. - The deprecated synchronous body decoding methods have been removed: 
body.decodedBuffer,body.text,body.jsonandbody.formData. They should be replaced with thebody.getDecodedBuffer(),.getText(),.getJson()and.getFormData()asynchronous methods instead. - The body property on aborted request event data has been removed (previously it was present but always empty).
 
 - All rule definition that didn't start with 
 - When returning a result with a 
bodyorjsonfield from a callback (thenCallback,beforeRequestorbeforeResponse), the request or response body will now be automatically encoded to match itscontent-encodingheader. PreviouslytransformRequest/Responseresults were automatically encoded but nothing else. To return raw data that should not be encoded automatically, returnrawBodyinstead with a Buffer/Uint8Array, and that will be used as-is with no encoding applied. - Mockttp is now considerably stricter about preserving raw header data (i.e. header order, duplicate headers and heading name casing) when reporting and proxying requests. Officially this is not semantically meaningful in HTTP, and should not affect any correct server/client implementations, but in practice some tools may behave differently. For Mockttp users, this means:
- All exposed requests & responses now include both a 
headerobject (lowercased header string keys to single-string or array-of-string values) and arawHeaderarray (an array of [string name, string value] pairs, with the exact order & casing that they were received). - When using passthrough rules, proxied traffic preserves the exact header formatting for upstream requests and returned responses where possible. The one case when this isn't possible is when setting headers with a 
transformRequest/Responseobject orbeforeRequest/Responsecallback. In that case, the headers will be normalized before forwarding, lowercasing header names and potentially changing header order. 
 - All exposed requests & responses now include both a 
 - All 
.on(event)subscriptions are now reset when a Mockttp instance resets, either due tomockServer.reset()or.stop()and.start()(previously only rules were reset). - Incoming websockets that don't match any rule are now rejected with a 503 (previously they were automatically proxied by default). This matches the behaviour for unmatched HTTP requests. To continue proxying websocket traffic, define an explicit rule like 
mockServer.forAnyWebSocket().thenPassThrough(). 
Other.changes:
- Added forPort and forHostname matchers, for more precise host matching (in addition to forHost, which matches the host header including some implicit header behaviour)
 - Added support for multiple fallback rules with 
forUnmatchedRequest(), added support for using matchers on fallback rules, and addedasPriority(n)to define multiple custom layers of multiple rules at different priorities. - Added 
thenRejectConnectionto reject websocket connections with a given HTTP response.