Fake some Feathers dependencies in service unit tests. Starter for your own customized fakes
appand database services such as
The following example is from
It may be run with
npm run test:only.
In this example we want to perform some unit tests on
feathers-service-verify-reset's resend method,
so we need to fake its Feathers dependencies
We would be running integration tests if we used Feathers' actual
and such tests would be more complicated.
const feathersFakes = ;const verifyResetService = service;const testUsersDb = // faked in-memory database_id: 'a' email: 'a' isVerified: false verifyToken: '000' verifyExpires: Date + 5000;;
It can be difficult to fake dependencies when running unit tests. This package provides fakes for the most common dependencies in a Feathers' project.
npm install feathers-tests-fake-app-users --save-dev in your project folder.
You can then require the utilities.
/src on GitHub contains the ES6 source.
It will run on Node 6+ without transpiling.
Running the Example
test/example.js is described above. It runs as part of the tests.
See Code Example above.
The exports in
src/index.js are fully documented.
npm test to run tests.
npm run cover to run tests plus coverage.
MIT. See LICENSE.