Property based testing for AVA based on fast-check
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';
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 supportfast-check ^1.0.0