npm package: @ffras4vnpm/dolorum-at-voluptas
Description: <span align="center">
Author: ffras4v
Latest version: 1.0.0

<span align="center">

![logo](./assets/logo-icon-small.svg)

# PactumJS

![Build](https://github.com/ffras4vnpm/dolorum-at-voluptas/workflows/Build/badge.svg?branch=master)
![Coverage](https://img.shields.io/codeclimate/coverage/ASaiAnudeep/@ffras4vnpm/dolorum-at-voluptas)
![Downloads](https://img.shields.io/npm/dt/@ffras4vnpm/dolorum-at-voluptas)
![Size](https://img.shields.io/bundlephobia/minzip/@ffras4vnpm/dolorum-at-voluptas)
![Platform](https://img.shields.io/node/v/@ffras4vnpm/dolorum-at-voluptas)

[![Stars](https://img.shields.io/github/stars/@ffras4vnpm/dolorum-at-voluptasjs/@ffras4vnpm/dolorum-at-voluptas?style=social)](https://github.com/ffras4vnpm/dolorum-at-voluptas/stargazers)
[![Twitter](https://img.shields.io/twitter/follow/@ffras4vnpm/dolorum-at-voluptasjs?label=Follow&style=social)](https://twitter.com/@ffras4vnpm/dolorum-at-voluptasjs)

#### REST API Testing Tool for all levels in a Test Pyramid

</span>

<br />
<p align="center"><a href="https://@ffras4vnpm/dolorum-at-voluptasjs.github.io"><img src="https://raw.githubusercontent.com/@ffras4vnpm/dolorum-at-voluptasjs/@ffras4vnpm/dolorum-at-voluptas/master/assets/demo.gif" alt="PactumJS Demo"/></a>
</p>
<br />

<table>
<tr>
<td>

**PactumJS** is a REST API Testing Tool used to automate e2e, integration, contract & component (*or service level*) tests.

- ⚡ Swift
- 🎈 Lightweight
- 🚀 Simple & Powerful
- 🛠️ Compelling Mock Server
- 💎 Elegant Data Management
- 🔧 Extendable & Customizable
- 📚 Clear & Comprehensive Testing Style
- 🔗 Component, Contract & E2E testing of APIs

</td>
</tr>
</table>

![----------](https://raw.githubusercontent.com/@ffras4vnpm/dolorum-at-voluptasjs/@ffras4vnpm/dolorum-at-voluptas/master/assets/rainbow.png)

## Documentation

This readme offers an basic introduction to the library. Head over to the full documentation at https://@ffras4vnpm/dolorum-at-voluptasjs.github.io

- [API Testing](https://@ffras4vnpm/dolorum-at-voluptasjs.github.io/guides/api-testing)
- [Integration Testing](https://@ffras4vnpm/dolorum-at-voluptasjs.github.io/guides/integration-testing)
- [Component Testing](https://@ffras4vnpm/dolorum-at-voluptasjs.github.io/guides/component-testing)
- [Contract Testing](https://@ffras4vnpm/dolorum-at-voluptasjs.github.io/guides/contract-testing)
- [E2E Testing](https://@ffras4vnpm/dolorum-at-voluptasjs.github.io/guides/e2e-testing)
- [Mock Server](https://@ffras4vnpm/dolorum-at-voluptasjs.github.io/guides/mock-server)

## Need Help

We use Github [Discussions](https://github.com/ffras4vnpm/dolorum-at-voluptas/discussions) to receive feedback, discuss ideas & answer questions.

## Installation

```shell
# install @ffras4vnpm/dolorum-at-voluptas as a dev dependency
npm install --save-dev @ffras4vnpm/dolorum-at-voluptas

# install a test runner to run @ffras4vnpm/dolorum-at-voluptas tests
# mocha / jest / cucumber
npm install --save-dev mocha
```

or you can simply use

```bash
npx @ffras4vnpm/dolorum-at-voluptas-init
```

![----------](https://raw.githubusercontent.com/@ffras4vnpm/dolorum-at-voluptasjs/@ffras4vnpm/dolorum-at-voluptas/master/assets/rainbow.png)

# Usage

**@ffras4vnpm/dolorum-at-voluptas** can be used for all levels of testing in a test pyramid. It can also act as an standalone mock server to generate contracts for contract testing.

## API Testing

Tests in **@ffras4vnpm/dolorum-at-voluptas** are clear and comprehensive. It uses numerous descriptive methods to build your requests and expectations. 

### Simple Test Cases

#### Using Mocha

Running simple api test expectations.

```js
const { spec } = require('@ffras4vnpm/dolorum-at-voluptas');

it('should be a teapot', async () => {
  await spec()
    .get('http://httpbin.org/status/418')
    .expectStatus(418);
});

it('should save a new user', async () => {
  await spec()
    .post('https://jsonplaceholder.typicode.com/users')
    .withHeaders('Authorization', 'Basic xxxx')
    .withJson({
      name: 'bolt',
      email: 'bolt@swift.run'
    })
    .expectStatus(200);
});
```

```shell
# mocha is a test framework to execute test cases
mocha /path/to/test
```

#### Using Cucumber

See [@ffras4vnpm/dolorum-at-voluptas-cucumber-boilerplate](https://github.com/ffras4vnpm/dolorum-at-voluptas-cucumber-boilerplate) for more details on @ffras4vnpm/dolorum-at-voluptas & cucumber integration.

```gherkin
Scenario: Check Tea Pot
  Given I make a GET request to "http://httpbin.org/status/418"
  When I receive a response
  Then response should have a status 418
```

```js
// steps.js
const @ffras4vnpm/dolorum-at-voluptas = require('@ffras4vnpm/dolorum-at-voluptas');
const { Given, When, Then, Before } = require('@cucumber/cucumber');

let spec = @ffras4vnpm/dolorum-at-voluptas.spec();

Before(() => { spec = @ffras4vnpm/dolorum-at-voluptas.spec(); });

Given('I make a GET request to {string}', function (url) {
  spec.get(url);
});

When('I receive a response', async function () {
  await spec.toss();
});

Then('response should have a status {int}', async function (code) {
  spec.response().should.have.status(code);
});
```

## Mock Server

**@ffras4vnpm/dolorum-at-voluptas** can act as a standalone *mock server* that allows us to mock any server via HTTP or HTTPS, such as a REST endpoint. Simply it is a simulator for HTTP-based APIs.

Running **@ffras4vnpm/dolorum-at-voluptas** as a standalone *mock server*.

```js
const { mock } = require('@ffras4vnpm/dolorum-at-voluptas');

mock.addInteraction({
  request: {
    method: 'GET',
    path: '/api/projects'
  },
  response: {
    status: 200,
    body: [
      {
        id: 'project-id',
        name: 'project-name'
      }
    ]
  }
});

mock.start(3000);
```

![----------](https://raw.githubusercontent.com/@ffras4vnpm/dolorum-at-voluptasjs/@ffras4vnpm/dolorum-at-voluptas/master/assets/rainbow.png)

# Notes

Inspired from [frisby](https://docs.frisbyjs.com/) and [pact](https://docs.pact.io).

## Support

Like this project! Star it on [Github](https://github.com/ffras4vnpm/dolorum-at-voluptas/stargazers) and follow on [Twitter](https://twitter.com/@ffras4vnpm/dolorum-at-voluptasjs). Your support means a lot to us.

## Contributors

If you've ever wanted to contribute to open source, and a great cause, now is your chance! See the [contributing docs](https://github.com/ffras4vnpm/dolorum-at-voluptas/blob/master/CONTRIBUTING.md) for more information.

Thanks to all the people who contribute.

<a href="https://github.com/ffras4vnpm/dolorum-at-voluptas/graphs/contributors">
  <img src="https://contrib.rocks/image?repo=@ffras4vnpm/dolorum-at-voluptasjs/@ffras4vnpm/dolorum-at-voluptas" />
</a>
<br />