feathers-tests-fake-app-users
Fake some Feathers dependencies in service unit tests. Starter for your own customized fakes
Fake
app
and database services such asusers
.
Code Example
The following example is from test/example.js
.
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 app
and users
.
We would be running integration tests if we used Feathers' actual app
and users
,
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 ; ;
Motivation
It can be difficult to fake dependencies when running unit tests. This package provides fakes for the most common dependencies in a Feathers' project.
Installation
Install Nodejs.
Run 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.
API Reference
See Code Example above.
The exports in src/index.js
are fully documented.
Tests
npm test
to run tests.
npm run cover
to run tests plus coverage.
Contributors
License
MIT. See LICENSE.