Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tape-testcheck

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tape-testcheck

Use Testcheck with Tape test runner

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

Tape Testcheck

Build Status

A Tape extension to use Testcheck with Tape.

Usage

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

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:

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

A basic test

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!'
    );
});
# Outputs:
$ ok 1 it works!

With Options

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'
    );
});
# outputs
$ ok 1 works with options

A failing test

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!'
    );
});
# 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.

Keywords

FAQs

Package last updated on 23 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc