Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/b1f6c1c4/jest-mongoose
Mongoose integration test made easy and terse.
https://github.com/b1f6c1c4/jest-mongoose
integration-testing javascript jest jest-mongoose mongodb mongoose testing unit-testing
Last synced: 8 days ago
JSON representation
Mongoose integration test made easy and terse.
- Host: GitHub
- URL: https://github.com/b1f6c1c4/jest-mongoose
- Owner: b1f6c1c4
- License: mit
- Created: 2018-02-24T06:07:48.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-12T12:57:40.000Z (over 1 year ago)
- Last Synced: 2024-09-23T01:59:57.148Z (about 1 month ago)
- Topics: integration-testing, javascript, jest, jest-mongoose, mongodb, mongoose, testing, unit-testing
- Language: JavaScript
- Homepage:
- Size: 705 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# jest-mongoose
[![Appveyor Build](https://img.shields.io/appveyor/build/b1f6c1c4/jest-mongoose?style=flat-square)](https://ci.appveyor.com/project/b1f6c1c4/jest-mongoose)
> Mongoose integration test made easy and terse.
This package helps you do mongoose integration test at ease.
* Easy to use. Terse and intuitive API.
* MongoDB connection is managed by yourself.
* No giant binary dependencies like `mongodb-download`.## Pre-requisites
This module requires Jest and Mongoose.
## Installation
```sh
$ npm i --save-dev jest-mongoose
```
## Usage> For a complete working demo, see the `example` folder.
```js
const { models, make, mer, check } = require('./bundle');
const { createUser } = require('../userManagement');describe('createUser', () => {
it('should make a new user', async () => {
// Call the function to be tested
await createUser();
// Check if the result is correct
await check.User({
_id: 'the-id',
name: 'the-name',
});
});it('should handle duplication insertion', async () => {
// Setup database records is simple
await make.User({
_id: 'the-id',
name: 'my-name-is-evil',
});
const result = await createUser();
// Check the return value
expect(result).toBeInstanceOf(Error);
// Check the previous record is intact
await check.User({
_id: 'the-id',
name: 'my-name-is-evil',
});
});
});
```## License
MIT