@lykmapipo/mongoose-test-helpers
mongoose test helpers
Last updated 19 days ago by lykmapipo .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @lykmapipo/mongoose-test-helpers 
SYNC missed versions from official npm registry.

mongoose-test-helpers

Build Status Dependencies Status

mongoose test helpers.

Requirements

  • NodeJS v9.3+

Install

$ npm install --save mongoose @lykmapipo/mongoose-test-helpers

Usage

const { connect, clear, drop } = require('@lykmapipo/mongoose-test-helpers');

before(done => connect(done));

after(done => clear(done));

after(done => drop(done));

API

connect([url: String], done: Function)

Establish connection using provided connection string, process.env.MONGODB_URI or default to test database

Example:

before(done => connect(done));

clear([...modelNames: String], done: Function)

Clear data of specified modelNames. If none provided all models will be cleared.

Example

after(done => clear('User', 'Profile', done));
after(done => clear(done));

drop(done: Function)

Deletes the test database, including all collections, documents, and indexes.

Example

after(done => drop(done));

disconnect([url: String], done: Function)

Close all connection used in test

Example

after(done => disconnect(done));

Testing

  • Clone this repository

  • Install all development dependencies

$ npm install
  • Then run test
$ npm test

Contribute

It will be nice, if you open an issue first so that we can know what is going on, then, fork this repo and push in your ideas. Do not forget to add a bit of test(s) of what value you adding.

Licence

The MIT License (MIT)

Copyright (c) 2018 lykmapipo & Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Current Tags

  • 0.7.46                                ...           latest (19 days ago)

64 Versions

  • 0.7.46                                ...           19 days ago
  • 0.7.45                                ...           25 days ago
  • 0.7.44                                ...           a month ago
  • 0.7.43                                ...           a month ago
  • 0.7.42                                ...           a month ago
  • 0.7.41                                ...           2 months ago
  • 0.7.40                                ...           2 months ago
  • 0.7.39                                ...           2 months ago
  • 0.7.38                                ...           3 months ago
  • 0.7.37                                ...           3 months ago
  • 0.7.36                                ...           3 months ago
  • 0.7.35                                ...           4 months ago
  • 0.7.34                                ...           4 months ago
  • 0.7.33                                ...           4 months ago
  • 0.7.32                                ...           4 months ago
  • 0.7.31                                ...           4 months ago
  • 0.7.30                                ...           4 months ago
  • 0.7.29                                ...           4 months ago
  • 0.7.28                                ...           6 months ago
  • 0.7.27                                ...           6 months ago
  • 0.7.26                                ...           6 months ago
  • 0.7.25                                ...           7 months ago
  • 0.7.24                                ...           8 months ago
  • 0.7.23                                ...           8 months ago
  • 0.7.22                                ...           8 months ago
  • 0.7.21                                ...           8 months ago
  • 0.7.20                                ...           8 months ago
  • 0.7.19                                ...           8 months ago
  • 0.7.18                                ...           9 months ago
  • 0.7.17                                ...           9 months ago
  • 0.7.16                                ...           10 months ago
  • 0.7.15                                ...           a year ago
  • 0.7.14                                ...           a year ago
  • 0.7.13                                ...           a year ago
  • 0.7.12                                ...           a year ago
  • 0.7.11                                ...           a year ago
  • 0.7.10                                ...           a year ago
  • 0.7.9                                ...           a year ago
  • 0.7.8                                ...           a year ago
  • 0.7.7                                ...           a year ago
  • 0.7.6                                ...           a year ago
  • 0.7.5                                ...           a year ago
  • 0.7.4                                ...           a year ago
  • 0.7.3                                ...           a year ago
  • 0.7.2                                ...           a year ago
  • 0.7.1                                ...           a year ago
  • 0.7.0                                ...           a year ago
  • 0.6.0                                ...           a year ago
  • 0.5.4                                ...           a year ago
  • 0.5.3                                ...           a year ago
  • 0.5.2                                ...           a year ago
  • 0.5.1                                ...           a year ago
  • 0.5.0                                ...           a year ago
  • 0.4.0                                ...           a year ago
  • 0.3.2                                ...           a year ago
  • 0.3.1                                ...           a year ago
  • 0.3.0                                ...           a year ago
  • 0.2.4                                ...           a year ago
  • 0.2.3                                ...           a year ago
  • 0.2.2                                ...           a year ago
  • 0.2.1                                ...           a year ago
  • 0.2.0                                ...           a year ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 40
Last Day 0
Last Week 0
Last Month 93
Dependencies (8)
Dev Dependencies (9)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |