cypress-mongo-seeder
A tool to quickly populate your mongo db from a set of .json files. The package prepared for seed database before each test on Cypress. You can use as a Cypress plugin or independently.
Setup
$ npm install --save-dev cypress-mongo-seeder or $ yarn add --dev cypress-mongo-seeder
Usage
seedAll
Read all json files in specified directory and insert them to mongodb. (File names are collection names)
seedAll: mongoUri: string dataFolder: string dropCollection?: boolean Promise<any>;
As a Cypress plugin
cypress/plugins/index.js
const path = ;const seeder = ; const mongouri = 'mongodb://localhost:27017/dummy-db';const folder = './data';const dropCollections = true; module { ;};
seedSingleCollection
Reads a json file and inserts content to mongo. (File name is collection name )
seedSingleCollection: mongoUri: string fileAbsolutePath: string dropCollection?: boolean Promise<any>;
const path = ;const seeder = ; const mongouri = 'mongodb://localhost:27017/dummy-main';const fileFullPath = path;const dropCollection = true; seeder ;
Contributing
- Fork the project
- Add feature(s)
- Add tests for it
- Submit pull request
Enjoy!