Coder Social home page Coder Social logo

ava-fast-check's Introduction

Property based testing for AVA based on fast-check

Build Status npm version

Bring the power of property based testing framework fast-check into ava. ava-fast-check simplifies the integration of fast-check into ava testing framework.

Getting started

Install ava-fast-check and its peer dependencies:

npm install --save-dev ava fast-check ava-fast-check

Example

import { testProp, fc } from 'ava-fast-check';

// for all a, b, c strings
// b is a sustring of a + b + c
testProp('should detect the substring', [fc.string(), fc.string(), fc.string()], (a, b, c) => {
  return (a + b + c).includes(b);
});

Please note that the properties accepted by ava-fast-check as input can either be synchronous or asynchronous (even just PromiseLike instances).

Advanced

If you want to forward custom parameters to fast-check, testProp accepts an optional fc.Parameters (more).

ava-fast-check also comes with .only, .skip and .failing from ava.

import { testProp, fc } from 'ava-fast-check';

testProp('should replay the test for the seed 4242', [fc.nat(), fc.nat()], (a, b) => {
  return a + b === b + a;
}, { seed: 4242 });

testProp.failing('should be skipped', [fc.fullUnicodeString()], text => {
  return text.length === [...text].length;
});

Minimal requirements

  • ava >=0.1.0 for its Promise support
  • fast-check ^1.0.0

ava-fast-check's People

Contributors

codelenny avatar dubzzz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.