# certain

> An Assertion Library

Latest version **1.8.0** (published 2015-11-08) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.8.0 |
| Published | 2015-11-08 |
| First published | 2014-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Sam Newman |
| Maintainers | sonewman |
| Keywords | assertion, library, certain |

## Links

- npm: https://www.npmjs.com/package/certain
- Repository: https://github.com/sonewman/certain
- Issues: https://github.com/sonewman/certain/issues
- npm.io page: https://npm.io/package/certain

## Dependencies (5)

- [eqls](https://npm.io/package/eqls.md) ^1.0.0
- [inherits](https://npm.io/package/inherits.md) ^2.0.1
- [util-extend](https://npm.io/package/util-extend.md) ^1.0.1
- [core-util-is](https://npm.io/package/core-util-is.md) ^1.0.1
- [readable-stream](https://npm.io/package/readable-stream.md) ^1.1.13

## Recent versions

- 1.8.0 (latest) — 2015-11-08
- 1.7.1 — 2015-07-03
- 1.7.0 — 2015-07-03
- 1.6.0 — 2015-06-07
- 1.5.0 — 2015-04-28
- 1.4.0 — 2014-10-12
- 1.3.0 — 2014-10-05
- 1.2.0 — 2014-10-04
- 1.1.0 — 2014-09-26
- 1.0.1 — 2014-09-26
- 1.0.0 — 2014-09-26

## README

# Certain
Certain is a simple assertion library.

Install:
```bash
$ npm install certain
```

Usage is pretty simple:
```javascript
var certain = require('certain')

certain('a').equals('a')

certain(false).is.true() // this will throw an AssertionError
```

## API

### certain(actual)
main *certain* method is called with the actual value then there are chained methods which allow the actual value to be compared to the corresponding expected value.

If the assertion is not correct **certain** will throw an AssertionError (this means you can use your preferred test suite provided that it fails the test on error)

There are also a number of chained properties which are available to improve semantics for test readability these are:`be, to, does, is`

For each of the below assertion methods it is possible to invert the assertion type by using: `not, doesnt` for example: `certain('a').does.not.equal('b')`




### #equals(expected, msg) & #*not*.equal(expected, msg)
Assert that actual value triple equals to the expected value
```javascript
certain('a').equals('a')

certain('a').equals('b') // will throw AssertionError

certain('a').does.not.equal('b')

certain('a').does.not.equal('a') // will throw AssertionError

certain('a').does.notEqual('b')

certain('a').does.notEqual('a') // will throw AssertionError
```

### #deepEquals(expected, msg) & #*not*.deepEqual(expected, msg)
Assert that the actual value deepEquals to expected (this checks the values of properties of a specified object rather than references)
```javascript
certain({ a: 1 }).deepEquals({ a: 1 })

certain({ a: 1 }).deepEquals({ a: 2, b: 3 }) // will throw AssertionError

certain({ a: 1 }).does.not.deepEqual({ a: 2, b: 3 })

certain({ a: 1 }).does.not.deepEqual({ a: 1 }) // will throw AssertionError

certain({ a: 1 }).does.notDeepEqual({ a: 2, b: 3 })

certain({ a: 1 }).does.notEqls({ a: 1 }) // will throw AssertionError
```

### #is.true( msg) & #is.*not*.true(msg)
Assert that actual value is or is not equal to *true*
```javascript
certain(true).is.true('It is true!')

certain(false).is.true() // will throw AssertionError

certain(false).is.not.true()

certain(true).is.not.true() // will throw AssertionError
```

### #is.false(msg) & #is.*not*.false(msg)
Assert that actual value is or is not equal to *false*
```javascript
certain(false).is.false('It is false!')

certain(true).is.false() // will throw AssertionError

certain(true).is.not.false()

certain(false).is.not.false() // will throw AssertionError
```

### #is.ok(msg) & #is.*not*.ok(msg)
Assert that actual value is *truthy* by checking: Boolean(expected)
```javascript
certain(1).is.ok('It is OK!')

certain(0).is.ok() // will throw AssertionError

certain(false).is.not.ok()
certain(null).is.not.ok()
certain(undefined).is.not.ok()

certain(true).is.not.ok() // will throw AssertionError
```
### #throws(msg) & #does.*not*.throw(msg)
This expects that the actual value passed is a function and will assert if this function
throws an error when called
```javascript
certain(function () {
  throw new Error()
}).throws()

certain(function () {
  return true
}).throws() // will throw AssertionError

certain(function () {
  return false
}).doesnt.throw()

certain(function () {
  throw new Error()
}).does.not.throw() // will throw AssertionError
```

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