# tape-testcheck

> Use Testcheck with Tape test runner

Latest version **1.1.1** (published 2015-12-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install tape-testcheck
pnpm add tape-testcheck
yarn add tape-testcheck
bun add tape-testcheck
```

## 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.1.1 |
| Published | 2015-12-23 |
| First published | 2015-10-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | npbee |
| Maintainers | npbee |
| Keywords | tape, testcheck |

## Links

- npm: https://www.npmjs.com/package/tape-testcheck
- Repository: https://github.com/npbee/tape-testcheck
- Homepage: https://github.com/npbee/tape-testcheck#readme
- Issues: https://github.com/npbee/tape-testcheck/issues
- npm.io page: https://npm.io/package/tape-testcheck

## Dependencies (2)

- [tape](https://npm.io/package/tape.md) ^4.2.1
- [testcheck](https://npm.io/package/testcheck.md) ^0.1.4

## Recent versions

- 1.1.1 (latest) — 2015-12-23
- 0.1.1 — 2015-11-18
- 0.1.0 — 2015-10-16

## README

# Tape Testcheck

[![Build Status](https://travis-ci.org/npbee/tape-testcheck.svg)](https://travis-ci.org/npbee/tape-testcheck)

A [Tape extension](https://github.com/atabel/extend-tape) to use 
[Testcheck](https://github.com/leebyron/testcheck-js) with 
[Tape](https://github.com/substack/tape).  

## Usage

To have access to the `t.check` method, you need to extend tape with the exported
`check` function.

```javascript
import tape from 'tape';
import addAssertions from 'extend-tape';
import check from 'tape-testcheck';

// Add the `check` assertion
const test = addAssertions(tape, { check });

// Now you can test away
test('Something', t => {
    t.check(...);
});
```

For convenience, the `gen` and `sample` methods are re-exported for usage with
your checks:

```javascript
import tape from 'tape';
import addAssertions from 'extend-tape';
import check, { gen, sample } from 'tape-testcheck';
```

### A basic test

```javascript
import tape from 'tape';
import addAssertions from 'extend-tape';
import check, { gen, sample } from 'tape-testcheck';

const test = addAssertions(tape, { check });

test('Something', t => {
    t.check(
        [gen.int],
        num => typeof num === 'number',
        'it works!'
    );
});
```

```bash
# Outputs:
$ ok 1 it works!
```

### With Options

```javascript
import tape from 'tape';
import addAssertions from 'extend-tape';
import check, { gen, sample } from 'tape-testcheck';

const test = addAssertions(tape, { check });

test('Something', t => {
    // with options
    t.check(
        [gen.int],
        num => typeof num === 'number',
        { times: 10 },
        'works with options'
    );
});
```

```bash
# outputs
$ ok 1 works with options
```

### A failing test

```javascript
import tape from 'tape';
import addAssertions from 'extend-tape';
import check, { gen, sample } from 'tape-testcheck';

const test = addAssertions(tape, { check });

test('Something', t => {

    t.check(
        [gen.int],
        num => typeof num === 'string',
        'it fails!'
    );
});
```

```bash
# Outputs:
$ not ok 1 it fails!
  ---
    operator: fail
    expected: |-
      { result: true }
    actual: |-
      { fail: [ 0 ], 'failing-size': 0, 'num-tests': 1, result: false, shrunk: { depth: 0, result: false, smallest: [ 0 ], 'total-nodes-visited': 0 } }
    at: ...
```


## API

### t.check(generators, propertyFn, options, msg)

- `generators`: An array of testcheck generators
- `propertyFn`: The testcheck property function to run
- `options`: Testcheck options
- `msg`: The message to use in the test (same as any other Tape message, e.g.
  `t.ok(value, msg)`

Run a testcheck property on `propertyFn` with the provided `generators` and
`options`.  The `msg` will be passed to the `t.pass` and `t.fail` methods.

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