dunkin
Seed MongoDB collections for integration testing
Installation
npm install --save-dev dunkin
Getting Started
The DunkinClient
class takes an optional single argument mongoUrl
.
mongoUrl
should be the fully qualified url to a running mongod
server.
If this argument is left out it will default to mongodb://localhost:27017/sandbox
.
See example usage below:
const DunkinClient = DunkinClient;const dunkin = ; // Define document modellet mockPostModel = title: 'SQL Injection Attacks' content: 'SQL injection is a hoax!' author: 'Bobby Tables'; // Define number of desired documentslet numberToCreate = 10; // Before tests: Seed MongoDB collectiondunkin; // Run your tests! // After tests Empty MongoDB collectiondunkin;
Random Content Generation
dunkin.seedCollection
will execute any model value that is a function. This allows for easy integration with faker to generate random content! See example below:
// In addition to requiring dunkin, require fakerconst faker = ; ... // Define model with faker functions as values// Functions will be invoked during generation processlet mockPostModel = title: fakerloremwords author: fakernamefirstName content: fakerloremsentences;
License
MIT (c) 2017 Joel Colucci