# assert-chain

> A chainable assertion interface for Node.

Latest version **1.0.1** (published 2019-03-01) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install assert-chain
pnpm add assert-chain
yarn add assert-chain
bun add assert-chain
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-03-01 |
| First published | 2019-02-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | def14nt |
| Maintainers | def14nt |
| Keywords | assert, chain, testing, test, assertion |

## Links

- npm: https://www.npmjs.com/package/assert-chain
- Repository: https://github.com/def14nt/assert-chain
- Homepage: https://github.com/def14nt/assert-chain#readme
- Issues: https://github.com/def14nt/assert-chain/issues
- npm.io page: https://npm.io/package/assert-chain

## Dependencies (1)

- [riteway](https://npm.io/package/riteway.md) ^6.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

- 1.0.1 (latest) — 2019-03-01
- 1.0.0 — 2019-02-28

## README

# Assert Chain

A chainable assertion interface for Node.

This module contains a chainable version of the riteway assertion library, and the native one. This library can be considered stable, as it does have tests included.

## API

The API is quite simple. Two functional classes are exported.

```ts
var chain = require('assert-chain');
var ritewayChain = new chain.RitewayChain(/* assertModule = require('riteway') */);
var assertChain = new chain.AssertChain(/* assertModule = require('assert') */);

ritewayChain
  .given('no arguments')
  .should('return 0')
  .actual(sum())
  .expected(0);

// You can access the state of a chain:
ritewayChain.__given__ === 'no arguments';
ritewayChain.__should__ === 'return 0';
ritewayChain.__actual__ === sum();
ritewayChain.__expected__ === 0;

// Chains auto-fire when all methods have been called.

// The condition() call can be changed to assertion() or cond() too.
assertChain
  .message('expected "value" to be a function')
  .condition(2);

// Or you can provide the message *with* the assertion.
var newAssertChain = new chain.AssertChain();

newAssertChain
  .condition(2, 'expected "value" to be a function');

// You can access the state of assertion chains, too:
newAssertChain.__assertion__ === 2;
newAssertChain.__message__ === 'expected "value" to be a function';

// You can also call the classes as functions, à la functional classes.
chain.AssertChain();
chain.RitewayChain();
```

## Issues and Features

If you wish to contribute anything to this project, submit a Pull Request or an Issue.

+ [GitHub Basics](https://youtu.be/0fKg7e37bQE)
+ [Git Basics](https://git-scm.com/book/en/v1/Getting-Started-Git-Basics)

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