redux-effects-fetch-fixture
This is an extension for redux-effects-fetch, which lets you define fixtures for your FETCH actions. Now you are able to develop completely without any REST backend.
Installation
npm install redux-effects-fetch-fixture
Usage
This package is designed to be used in conjunction with redux-effects. Install it like this:
; ; ; const fixtures = /* your fixtures */ ; const fetchMiddleware = isProduction ? fetch : ; createStore;
Define fixtures
The fixture definition is structured like this:
'<path>': httpResponsePromise
The path-string supports URL parameters using the :param
syntax.
response helpers
There are some response helpers to remove some boilerplate.
; // empty 200 responseresponses; // 200 response with bodyresponses; // delayed 200 responseresponses
The error helpers define a message
and kind
field in the response body. This will get more flexible in future
releases.
; // rejected promise with Error(message)responses; // 500 responseresponsesinternalServerError; // delayed 404 responseresponses // delayed 401 responseresponses // forbidden 403 responseresponses
Examples
A fixture could look like this
; const fixture = '/foo': // this delegates to another fixture // simple definition '/test': responses // define responses for different http methods 'user/:id': responses responses responses // simulate exceptions 'user/2': responsesinternalServerError ;
Build
To build the library
npm run build
Release
npm version [patch|minor|major]
npm publish
git push
git push --tags