Falcor SuperTest DataSource
A Falcor DataSource class for testing Falcor routes using SuperTest.
Testing with a Falcor Model has a few added benefits over testing w/ direct HTTP requests:
- requests are made using Falcor's path syntax, rather than the equivalent HTTP queryparams/request body
- responses are equivalent to what the client receives, e.g. by resolving refs
- enables tests against the model cache, e.g. ensuring that paths are properly invalidated after a call request
Testing against a Falcor Model will not test for overfetching or underfetching. E.g. if a route accidentally returns more data than it should, the extra data will be dropped silently by the Falcor Model. Similarly, if a route returns less data than it should, the model will silently make a subsequent request in order to finish building the jsonGraph snippet. Testing against a Falcor Model will ensure that the client eventually receives all the data it needs (just not necessarily as efficiently as possible).
Basic Usage
const falcor = ;const test = ;const SuperTestDataSource = ;const app = ; const model = source: '/api/model.json' app; ;
Advanced Usage
Take a look at test/index.js
, which is set up to run against a sample express/falcor-router app in example/example-router/
. The app runs against an in-memory SQLite DB, and is reinitialized for each test, ensuring all tests run in isolation against a fresh app state.