# node-jswiremock

> A library used for stubbing and mocking web services.

Latest version **0.2.1** (published 2019-06-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-jswiremock
pnpm add node-jswiremock
yarn add node-jswiremock
bun add node-jswiremock
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2019-06-04 |
| First published | 2018-12-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 55.2 KB |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| Author | Jaspreet Lidder |
| Maintainers | uuau99999 |
| Keywords | mock |

## Links

- npm: https://www.npmjs.com/package/node-jswiremock
- Repository: https://github.com/uuau99999/jswiremock
- Issues: https://github.com/uuau99999/jswiremock/issues
- npm.io page: https://npm.io/package/node-jswiremock

## Dependencies (5)

- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [express](https://npm.io/package/express.md) ~4.15.2
- [deep-equal](https://npm.io/package/deep-equal.md) ^1.0.1
- [body-parser](https://npm.io/package/body-parser.md) 1.17.1

## Alternatives

- [pagerjs](https://npm.io/package/pagerjs.md) — 60 weekly downloads
- [whistle.savefor-mock](https://npm.io/package/whistle.savefor-mock.md) — 4 weekly downloads
- [@crvouga/mockingbird-service-tempo](https://npm.io/package/@crvouga/mockingbird-service-tempo.md) — 0 weekly downloads
- [@crvouga/mockingbird-service-okta](https://npm.io/package/@crvouga/mockingbird-service-okta.md) — 0 weekly downloads
- [@crvouga/mockingbird-service-microsoft](https://npm.io/package/@crvouga/mockingbird-service-microsoft.md) — 0 weekly downloads

## Recent versions

- 0.2.1 (latest) — 2019-06-04
- 0.1.0 — 2019-01-28
- 0.0.9 — 2019-01-27
- 0.0.8 — 2019-01-17
- 0.0.7 — 2019-01-17
- 0.0.6 — 2019-01-16
- 0.0.5 — 2019-01-14
- 0.0.4 — 2018-12-29
- 0.0.3 — 2018-12-28
- 0.0.2 — 2018-12-28
- 0.0.1 — 2018-12-27

## README

# jswiremock [![Build Status](https://travis-ci.org/jlidder/jswiremock.svg?branch=master)](https://travis-ci.org/jlidder/jswiremock)

Miss WireMock in Java? This is the Nodejs sibling to WireMock. At least that is the goal! 

Jswiremock is a flexible http api mocking library.

## Right now in v0.3:

- Simple GET and POST requests can be mocked.
- Fixed and Dynamic URL stubs (ex: /account/:varying_var/get/)
- Fixed and Dynamic Query parameters (ex: /account/234234?active=:var&cool=true

## Installation
     $ npm install jswiremock


## How to use it?

```javascript
var jswiremocklib, jswiremock, stubFor, get, post, urlEqualTo, a_response;
jswiremocklib = require('../jswiremock'), jswiremock = jswiremocklib.jswiremock, stubFor = jswiremocklib.stubFor, get = jswiremocklib.get, post = jswiremocklib.post, urlEqualTo = jswiremocklib.urlEqualTo, a_response = jswiremocklib.a_response, stopJSWireMock = jswiremocklib.stopJSWireMock;

var jswiremock = new jswiremock(5001); //port

stubFor(jswiremock, get(urlEqualTo("/account/:varying_var/get/"))
    .willReturn(a_response()
        .withStatus(200)
        .withHeader({"Content-Type": "application/json"})
        .withBody("[{\"status\":\"success\"}]")));

stubFor(jswiremock, post(urlEqualTo("/login"), {username: "captainkirk", password: "enterprise"})
    .willReturn(a_response()
        .withStatus(200)
        .withHeader({})
        .withBody("")));

/*
 * Actual call to the stub below.
 */
var request = require("request");
var assert = require('assert');

request({
    uri: "http://localhost:5001/account/4444321/get/",
    method: "GET"
}, function(error, response, body) {
    assert.strictEqual(body, "[{\"status\":\"success\"}]", 'get response is not the same.');
    jswiremock.stopJSWireMock();
});
```

## Issues or new feature requests

Please feel free to use github's built-in issue tracking feature.

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