An open API service indexing awesome lists of open source software.

https://github.com/testdouble/ought

A dumb assertion library with smart diffs for JavaScript
https://github.com/testdouble/ought

Last synced: about 2 months ago
JSON representation

A dumb assertion library with smart diffs for JavaScript

Awesome Lists containing this project

README

          

# ought

This module combines your underlying Node.js runtime's
[assert](https://nodejs.org/api/assert.html) module's assertions with the
pleasant diffing output from the [ava](https://github.com/avajs/ava) test
runner (which is actually powered by
[concordance](https://github.com/concordancejs/concordance)).

To avoid adding unnecessary overhead to your tests, ought goes out of its way to
not `require` any of its diffing and printing dependencies unless one of your
assertions has actually failed.

## Usage

Install it:

```
npm install -D ought
```

Use it:

```js
const ought = require('ought')

module.exports = function myTest () {
const result = 34 + 43

ought.equal(result, 77)
}
```

The other method is `ought.notEqual`.

## API

### Assertions

* `ought.equal(actual, expected, message)` - Other than the pretty failure
message, behavior should exactly match
[assert.deepStrictEqual](https://nodejs.org/api/assert.html#assert_assert_deepstrictequal_actual_expected_message)
* `ought.notEqual(actual, expected, message)` - This one just calls [assert.notDeepStrictEqual](https://nodejs.org/api/assert.html#assert_assert_notdeepstrictequal_actual_expected_message)

We would've kept the original assertion names, but we hate typing.

### Configuration

You can configure ought with `ought.config`. Defaults follow:

```js
ought.config({
color: true
})
```

## Output

What does the output look like? The theme's colors need some tweaking, but for
now the output of
[test.js](https://github.com/testdouble/ought/blob/a0bfcb69c3d06f4cdff86649010479a387852915/test.js#L5-L33)'s
failing test looks like this:

screen shot 2019-02-18 at 6 51 21 pm

## Code of Conduct

This project follows Test Double's [code of conduct](https://testdouble.com/code-of-conduct) for all community interactions, including (but not limited to) one-on-one communications, public posts/comments, code reviews, pull requests, and GitHub issues. If violations occur, Test Double will take any action they deem appropriate for the infraction, up to and including blocking a user from the organization's repositories.