Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sayegh7/goosemock
Lightweight in-memory mongoose mocking
https://github.com/sayegh7/goosemock
javascript mocking-framework mongoose nodejs
Last synced: 29 days ago
JSON representation
Lightweight in-memory mongoose mocking
- Host: GitHub
- URL: https://github.com/sayegh7/goosemock
- Owner: Sayegh7
- License: mit
- Created: 2018-08-30T14:19:35.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-28T17:15:16.000Z (almost 6 years ago)
- Last Synced: 2024-11-16T21:36:52.212Z (about 1 month ago)
- Topics: javascript, mocking-framework, mongoose, nodejs
- Language: JavaScript
- Homepage:
- Size: 34.2 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Goosemock
[![npm version](https://badge.fury.io/js/goosemock.svg)](https://badge.fury.io/js/goosemock)
![npm](https://img.shields.io/npm/dt/goosemock.svg)Goosemock is mongoose mocking framework. This package was created because we needed to write unit tests on a backend that used mongoose and we needed something to mock the behavior of mongoose but in a dynamic way. It is essentially an in memory database but without the need for a even a database server or any installations. All mongoose functions affect in-memory data data structures.
## Installation
Install Goosemock with npm
```bash
npm install goosemock
```## Usage
Using goosemock is simple. Simply require and run it after mongoose like so:
```javascript
const mongoose = require('mongoose')
const goosemock = require('goosemock')goosemock()
```
Now all calls to mongoose functions will be executed in-memory. Note also that even `mongoose.connect()` will no longer be able to connect to the server as it is intercepted by goosemock.