Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cpg1111/factorydude
A Node module to create mongoose objects for test data
https://github.com/cpg1111/factorydude
Last synced: 3 days ago
JSON representation
A Node module to create mongoose objects for test data
- Host: GitHub
- URL: https://github.com/cpg1111/factorydude
- Owner: cpg1111
- License: apache-2.0
- Created: 2015-01-16T03:53:37.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-03T14:07:19.000Z (over 9 years ago)
- Last Synced: 2024-10-13T02:44:00.735Z (24 days ago)
- Language: JavaScript
- Size: 253 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FactoryDude
A Node module to create mongoose objects for test data
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cpg1111/FactoryDude?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
To be used in test suites (mocha, chai, jasmine, etc) for features that use mongoose models.
Inspired by factory_girl### Install
```
npm install FactoryDude
```## Usage
```
var FactoryDude = require('FactoryDude');
var factoryDude = new FactoryDude();
```### Create a Factory
```
var newFixtureModel = factoryDude.factory(
,
,
);
/*
* returns a mongoose model that has been saved in the database
* and can be used just as any other mongoose models.
*/
```### Reference one factory in another factory
```
factoryDude.reference(, );
``````
var firstFixtureModel = factoryDude.factory(
'firstModel',
'./path/to/model',
{name: 'test', number: 1}
);
//creates a model with the name test and a number 1var secondFixtureModel = factoryDude.factory(
'secondModel',
'./path/to/model',
{name: factoryDude.reference('firstModel', 'name'), number: 2}
);
//creates a model with the name test and a number 2
```### Destroy a factory model that was already created
```
factoryDude.destroy();
``````
var firstFixtureModel = factoryDude.factory(
'firstModel',
'./path/to/model',
{name: 'test', number: 1}
);factoryDude.destroy('firstModel'); //'firstModel' is no longer in the database or a fixture
```## License
FactoryDude is licensed under the apache license.