New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@floogulinc/cypress-mongo-seeder

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@floogulinc/cypress-mongo-seeder

A cypress plugin to populate a mongo db from json files

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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 = require('path');
const seeder = require('cypress-mongo-seeder');

const mongouri = 'mongodb://localhost:27017/dummy-db';
const folder = './data';
const dropCollections = true;

module.exports = on => {
  on('task', {
    'seed:database': () => {
      return seeder.seedAll(mongouri, folder, dropCollections);
    },
  });
};

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 = require('path');
const seeder = require('../build');

const mongouri = 'mongodb://localhost:27017/dummy-main';
const fileFullPath = path.resolve(__dirname + '/data/users.json');
const dropCollection = true;

seeder
  .seedSingleCollection(mongouri, fileFullPath, dropCollection)
  .then(seeded => {
    console.log('Seeded -> ', seeded);
  });

Contributing

  1. Fork the project
  2. Add feature(s)
  3. Add tests for it
  4. Submit pull request

Enjoy!

Keywords

FAQs

Package last updated on 21 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc