Seamless REST/GraphQL API mocking library for browser and Node.js.
MIT License
Bot releases are hidden (Show)
Published by kettanaito about 2 years ago
Published by kettanaito over 2 years ago
Published by kettanaito over 2 years ago
Published by kettanaito over 2 years ago
req.destination
default value is now ""
(empty string), previously "document"
.req.redirect
default value is now ""follow"
, previously "manual"
.parseIsomorphicRequest()
function (#1316). Please use MockedRequest
class instead.req
instance:
req.priority
, indicates a priority of request relatively to other requests (default "auto"
);req.text()
, reads the request body as plain text;req.json()
, reads the request body as JSON;req.arrayBuffer()
, reads the request body as ArrayBuffer
;req.clone()
, clones a request instance (i.e. so its body could be read multiple times).req.body
is deprecated. Please use explicit request body reading methods: req.text()
, req.json()
, req.arrayBuffer()
(other methods, like req.formData()
are currently not supported).rest.post('/user', async (req, res, ctx) => {
const newUser = await req.json()
})
req.body
is still present for compatibility reasons but will be removed in the next releases.
Published by kettanaito over 2 years ago
Published by kettanaito over 2 years ago
Published by kettanaito over 2 years ago
Published by kettanaito over 2 years ago
Published by kettanaito over 2 years ago
Published by kettanaito over 2 years ago
Published by kettanaito over 2 years ago
Published by kettanaito over 2 years ago
Published by kettanaito over 2 years ago
Published by kettanaito over 2 years ago
Published by kettanaito over 2 years ago
undefined
, or early returns, from response resolvers, now does not perform request as-is, and is instead treated as a handler that didn't do anything. Please return req.passthrough()
if you wish to bypass a request.rest.get('/resource', (req, res, ctx) => {
// I want to perform this intercepted request as-is.
- return
+ return req.passthrough()
})
x-msw-request-id
request header (#713, #1022, #1024).x-msw-request-id
header on the request (#1024). Relies on the request.id
set by the interceptors (Node.js) or the requestId
generated by the worker (browser).