# redmock

> Mock Redis server for unit testing.

Latest version **1.0.0** (published 2016-03-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install redmock
pnpm add redmock
yarn add redmock
bun add redmock
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-03-02 |
| First published | 2016-03-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 5.7.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | Scott Guilbeaux |
| Maintainers | smokerbag |

## Links

- npm: https://www.npmjs.com/package/redmock
- Repository: https://github.com/smokerbag/redmock
- Homepage: https://github.com/smokerbag/redmock#readme
- Issues: https://github.com/smokerbag/redmock/issues
- npm.io page: https://npm.io/package/redmock

## Dependencies (1)

- [debug](https://npm.io/package/debug.md) 2.2.0

## Recent versions

- 1.0.0 (latest) — 2016-03-02

## README

# RedMock

[![Build Status](https://travis-ci.org/smokerbag/redmock.svg?branch=master)](https://travis-ci.org/smokerbag/redmock)
[![Coverage Status](https://coveralls.io/repos/github/smokerbag/redmock/badge.svg?branch=master)](https://coveralls.io/github/smokerbag/redmock?branch=master)
[![Dependency Status](https://david-dm.org/smokerbag/redmock.svg)](https://david-dm.org/smokerbag/redmock)

Mock [Redis](http://redis.io) server for [Node](https://nodejs.org) unit tests.

Requires Node version 5.7.0 or higher for the newest language features.

# Purpose

I created this project to help unit test an application that I was writing that used Redis for caching. I didn't want to stub out my client library code since I felt that would not be reliable enough, 
and I didn't want to get to functional/integration tests and find that my code was broken. I wanted to support sentinel and clustering, and couldn't find something that I felt would work, so I wrote this POS.

# Usage

## Starting the server

Call the start method after creating a new instance of the RedisServer class. This method returns an ES6 promise.

```javascript
const RedisServer = require('redmock');

let redisServer = new RedisServer();

redisServer.start().then((res) => {
  // Server is now up
}).catch((err) => {
  // Deal with error
});

```

## Stopping the server

Call the stop method. This method returns an ES6 promise. You do not have to worry about catching errors from this method.

```javascript

redisServer.stop().then((res) => {
  // Server is now stopped
});

```

## Example test

```javascript
// require/import needed crap

describe('SomeTestSpec', () => {
  
  let redisServer, underTest;

  // Start the server
  before((done) => {
    redisServer = new RedisServer();
    redisServer.start().then((res) => {
      done();
    }).catch((err) => {
      done(err);
    });
  });

  // Stop the server
  after((done) => {
    redisServer.stop().then((res) => {
      done();
    });
  });

  describe('#somemethod()', () => {

    beforeEach(() => {
      underTest = new UnderTest();
    });

    it('should test it', () => {
      return underTest.somemethod().should.eventually.equal(true);
    });

  });

});

```

---
_Source: https://npm.io/package/redmock · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
