Features
- Adds support for declaring runtime request handlers (#128, #187):
.use()
to prepend any request handlers. Any prepended request handlers take priority over existing ones, if their predicate match..restoreHandlers()
to mark any used one-time request handlers as unused, allowing them to affect network again..resetHandlers()
to remove any request handlers added on runtime. Optionally accepts a list of next request handlers that replace the initial handlers passed tosetupServer
/setupWorker
call.
- Adds support for one-time request handlers using
res.once()
. Such handles will respond with a given mocked response only once upon request match:
rest.get('/books', (req, res, ctx) => {
return res.once(ctx.json([1, 2, 3]))
})
Bug fixes
TS7016: Could not find a declaration file for module 'cookie'
- Fixes an outdated GitHub repository link in the
mockServiceWorker.js
file.