# rigorous

> Mocking and testing utilities for developing APIs with Swagger/OpenAPI

Latest version **0.3.2** (published 2019-08-01) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2019-08-01 |
| First published | 2019-03-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 14 |
| Unpacked size | 138.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | skonves |
| Keywords | testing, mocking, swagger, openapi, api, apis |

## Links

- npm: https://www.npmjs.com/package/rigorous
- npm.io page: https://npm.io/package/rigorous

## Dependencies (14)

- [uuid](https://npm.io/package/uuid.md) ^3.3.2
- [chance](https://npm.io/package/chance.md) ^1.0.18
- [express](https://npm.io/package/express.md) ^4.16.4
- [randexp](https://npm.io/package/randexp.md) ^0.5.3
- [prettier](https://npm.io/package/prettier.md) ^1.16.4
- [json-refs](https://npm.io/package/json-refs.md) ^3.0.12
- [typescript](https://npm.io/package/typescript.md) ^3.3.3
- [@types/uuid](https://npm.io/package/@types/uuid.md) ^3.4.4
- [body-parser](https://npm.io/package/body-parser.md) ^1.18.3
- [@types/express](https://npm.io/package/@types/express.md) ^4.16.1
- [openapi-router](https://npm.io/package/openapi-router.md) 0.0.6
- [@types/prettier](https://npm.io/package/@types/prettier.md) ^1.16.1
- [@types/body-parser](https://npm.io/package/@types/body-parser.md) ^1.17.0
- [swagger-ui-express](https://npm.io/package/swagger-ui-express.md) ^4.0.2

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 0.3.2 (latest) — 2019-08-01
- 0.3.1 — 2019-08-01
- 0.3.0 — 2019-07-25
- 0.2.16 — 2019-07-23
- 0.2.15 — 2019-07-13
- 0.2.14 — 2019-06-05
- 0.2.13 — 2019-05-13
- 0.2.12 — 2019-04-22
- 0.2.11 — 2019-03-30

## README

[![build](https://img.shields.io/travis/gpsinsight/rigorous.svg)](https://travis-ci.org/gpsinsight/rigorous)
[![code coverage](https://img.shields.io/codecov/c/gh/gpsinsight/rigorous.svg)](https://codecov.io/gh/gpsinsight/rigorous)
[![npm](https://img.shields.io/npm/v/rigorous.svg)](https://www.npmjs.com/package/rigorous)

# rigorous

Mocking and testing utilities for developing APIs with Swagger/OpenAPI

## Quickstart

### Run a mock server

The following example starts a mock server that hosts each of the spec files in the specified folder. The server will restart when any of the spec files are updated. The regex determines which files should be run. But default, any file ending with `.oas2.json` will be run.

```js
const { watch } = require('rigorous');

watch('/path/to/my/spec/folder', {
  port: 8080,
  regex: /^spec\.json$/,
});
```

### Generate integration tests

The following example will generate Mocha tests for negative cases based on the provided specs. The tests can then be run as you would run any suite of Mocha tests.

```js
const fs = require('fs');

const {
  createTestCases,
  createBadParameters,
  createMethodNotAllowed,
  createMissingParameters,
  createSmokeTests,
  generate,
} = require('rigorous');

const spec = fs.readFileSync('/path/to/spec.oas2.json');

createTestCases(spec, [
  createBadParameters,
  createMethodNotAllowed,
  createMissingParameters,
  createSmokeTests,
]).then(testCases =>
  fs.writeFileSync('/path/to/spec.tests.js', generate(testCases)),
);
```

## How to:

### Run this project

1.  Build the code: `npm run build`
1.  Run it! `npm start`

### Create and run tests

1.  Add tests by creating files with the `.tests.ts` suffix
1.  Run the tests: `npm t`
1.  Test coverage can be viewed at `/coverage/lcov-report/index.html`

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