# chai-return-bool

> Return a boolean with chai.js instead of raising an exception

Latest version **1.0.0** (published 2018-10-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install chai-return-bool
pnpm add chai-return-bool
yarn add chai-return-bool
bun add chai-return-bool
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-10-13 |
| First published | 2018-10-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Justin Lovinger |
| Maintainers | justinlovinger |
| Keywords | chai, testing, test |

## Links

- npm: https://www.npmjs.com/package/chai-return-bool
- Repository: https://github.com/JustinLovinger/chai-return-bool
- Homepage: https://github.com/JustinLovinger/chai-return-bool#readme
- Issues: https://github.com/JustinLovinger/chai-return-bool/issues
- npm.io page: https://npm.io/package/chai-return-bool

## Dependencies (1)

- [chai](https://npm.io/package/chai.md) ^4.2.0

## 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.0 (latest) — 2018-10-13

## README

[![Build Status](https://travis-ci.org/JustinLovinger/chai-return-bool.svg?branch=master)](https://travis-ci.org/JustinLovinger/chai-return-bool)
[![Coverage Status](https://coveralls.io/repos/github/JustinLovinger/chai-return-bool/badge.svg?branch=master)](https://coveralls.io/github/JustinLovinger/chai-return-bool?branch=master)
[![npm version](https://badge.fury.io/js/chai-return-bool.svg)](https://badge.fury.io/js/chai-return-bool)


# chai-return-bool

A simple utility library to return a boolean with [chai.js](https://github.com/chaijs/chai) instead of raising an exception.

## Installation

via [npm](https://github.com/npm/npm)

```
npm install chai-return-bool
```

# Usage

Say you are using `chai` to assert against a piece of code

```js
const expect = require('chai').expect;
// ...
expect(foo()).to.be.closeTo(10, 1e-10);
```

You want a boolean `true` or `false` instead of an exception. You can wrap the assertion with `chai-return-bool`.

```js
const expect = require('chai').expect;
const returnBool = require('chai-return-bool').returnBool;
// ...
returnBool(() => expect(foo()).to.be.closeTo(10, 1e-10)); // Returns: true or false
```

`chai-return-bool` works with all `chai` assertion styles.

## Async

If `block` returns a `Promise`, `returnBool` returns a `Promise` that resolves to `true` or `false`.

# API

```ts
/**
 * Call block and return true if it does not raise a chai.AssertionError
 * 
 * Return false if block returns a chai.AssertionError
 * 
 * If any other exception is raised, that exception will not be caught by returnBool.
 */
function returnBool<T>(block: () => T): T extends Promise<any> ? Promise<boolean> : boolean
```

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