New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mongoose-test

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-test

Test helpers for mongoose

latest
Source
npmnpm
Version
1.2.0
Version published
Maintainers
1
Created
Source

mongooose-test

A few test helper to make testing mongoose easier.

Build Status

##How to use

##Insert documents with some value.

    var RequireStringDummy = mongoose.model('DummyStringRequired', new mongoose.Schema({
        a: Number,
        b: {type: String, required: true},
        c: {type: String, required: true, enum: ['hongbosb', 'shijiesb']}
    }))
    var mongooseTest = require('mongoose-test')
        return mongooseTest.init(RequireStringDummy, [{a: 1}, {a: 2}]);
    }

##Insert documents with all random values.

    var RequireStringDummy = mongoose.model('DummyStringRequired', new mongoose.Schema({
        a: Number,
        b: {type: String, required: true},
        c: {type: String, required: true, enum: ['hongbosb', 'shijiesb']}
    }))
    var mongooseTest = require('mongoose-test')
        return mongooseTest.init(RequireStringDummy, new Array(3));
    }

When the inserted document contains some required fields that doesn't have value, mongooseTest will automatically generate some dummy data according its type. In the above example, we don't need to specify b and c these two required fields. But after call insertData we will still find some strings in these fields. So with this strategy, you only need to concentrate on the fields you care, let let mongoose-test do the rest work.

##Install

npm install --save mongoose-test

FAQs

Package last updated on 06 Feb 2016

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