All Projects → dubzzz → ava-fast-check

dubzzz / ava-fast-check

Licence: MIT license
Property based testing for AVA based on fast-check

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
shell
77523 projects

Projects that are alternatives of or similar to ava-fast-check

Fast Check
Property based testing framework for JavaScript (like QuickCheck) written in TypeScript
Stars: ✭ 2,604 (+5818.18%)
Mutual labels:  unit-testing, quickcheck, property-based-testing, generative-testing
kitimat
A library for generative, property-based testing in TypeScript and Jest.
Stars: ✭ 68 (+54.55%)
Mutual labels:  quickcheck, property-based-testing, generative-testing
quickcheck
Randomized testing for Prolog à la QuickCheck
Stars: ✭ 18 (-59.09%)
Mutual labels:  quickcheck, property-based-testing
quasar-testing
Testing Harness App Extensions for the Quasar Framework 1.0+
Stars: ✭ 142 (+222.73%)
Mutual labels:  unit-testing, ava
fuzz-rest-api
Derive property based testing fast-check into a fuzzer for REST APIs
Stars: ✭ 38 (-13.64%)
Mutual labels:  quickcheck, property-based-testing
Rapid
Rapid is a Go library for property-based testing that supports state machine ("stateful" or "model-based") testing and fully automatic test case minimization ("shrinking")
Stars: ✭ 213 (+384.09%)
Mutual labels:  quickcheck, property-based-testing
Fsharp Hedgehog
Release with confidence, state-of-the-art property testing for .NET.
Stars: ✭ 219 (+397.73%)
Mutual labels:  quickcheck, property-based-testing
Ava
Node.js test runner that lets you develop with confidence 🚀
Stars: ✭ 19,458 (+44122.73%)
Mutual labels:  unit-testing, ava
Qcstm
A simple state-machine framework for OCaml based on QCheck
Stars: ✭ 50 (+13.64%)
Mutual labels:  quickcheck, property-based-testing
Deepstate
A unit test-like interface for fuzzing and symbolic execution
Stars: ✭ 603 (+1270.45%)
Mutual labels:  unit-testing, property-based-testing
Tasty
Modern and extensible testing framework for Haskell
Stars: ✭ 499 (+1034.09%)
Mutual labels:  unit-testing, quickcheck
quick.py
Property-based testing library for Python
Stars: ✭ 15 (-65.91%)
Mutual labels:  quickcheck, property-based-testing
Qcheck
QuickCheck inspired property-based testing for OCaml.
Stars: ✭ 194 (+340.91%)
Mutual labels:  quickcheck, property-based-testing
Quickcheck State Machine
Test monadic programs using state machine based models
Stars: ✭ 192 (+336.36%)
Mutual labels:  quickcheck, property-based-testing
Rantly
Ruby Imperative Random Data Generator and Quickcheck
Stars: ✭ 241 (+447.73%)
Mutual labels:  quickcheck, property-based-testing
Swiftcheck
QuickCheck for Swift
Stars: ✭ 1,319 (+2897.73%)
Mutual labels:  quickcheck, property-based-testing
awesome-javascript-testing
🔧 Awesome JavaScript testing resources
Stars: ✭ 28 (-36.36%)
Mutual labels:  unit-testing, ava
Junit Quickcheck
Property-based testing, JUnit-style
Stars: ✭ 821 (+1765.91%)
Mutual labels:  quickcheck, property-based-testing
Quick check.js
A JS implementation of quick_check
Stars: ✭ 48 (+9.09%)
Mutual labels:  quickcheck, property-based-testing
Expecto
A smooth testing lib for F#. APIs made for humans! Strong testing methodologies for everyone!
Stars: ✭ 495 (+1025%)
Mutual labels:  unit-testing, property-based-testing

⚠️⚠️⚠️ Project moved to https://github.com/dubzzz/fast-check/tree/main/packages/ava ⚠️⚠️⚠️


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 substring of a + b + c
testProp('should detect the substring', [fc.string(), fc.string(), fc.string()], (t, a, b, c) => {
  t.true((a + b + c).includes(b));
});

The property is passed AVA's t argument for its first parameter, and the value of each arbitrary for the current test case for the rest of the parameters.

ava-fast-check supports all of AVA's assertions and like AVA, supports synchronous and asynchronous functions, including promises, observables, and callbacks. See AVA's documentation for more information.

Advanced

fast-check Parameters

testProp accepts an optional fc.Parameters for forwarding custom parameters to fast-check (more).

AVA Modifiers

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

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

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

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

AVA before/after Hooks

ava-fast-check exposes AVA's before/after hooks:

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

testProp.before(t => {
  connectToDatabase();
});

testProp(
  // ... omitted for brevity
);

testProp.after(t => {
  closeDatabaseConnection();
});

AVA Execution Context

ava-fast-check mirror's AVA's procedure for customizing the test execution context:

import { fc, testProp as anyTestProp, PropertyTestInterface } from '../src/ava-fast-check';

type TestContext = {
  state: string
};

const testProp = anyTestProp as PropertyTestInterface<TestContext>;

testProp(
  'should reach terminal state',
  [fc.string()],
  (t, received) => {
    // here t is typed as ExecutionContext<TestContext>
    console.log(t.context.state); // logs 'uninitialized'
    // ... omitted for brevity
  }
);

Minimal requirements

ava-fast-check AVA fast-check
^6.0.0 >=4.0.0 ^3.0.0
^5.0.0 >=4.0.0 ^2.0.0(2)(4)
^4.0.0 >=3.9.0(1) ^2.0.0(2)
^3.0.0 >=3.9.0(1) ^2.0.0(2)
^2.0.0 >=3.9.0(1) ^1.0.0
^1.0.0 >=0.1.0(3) ^1.0.0
  • (1) ava@>=3.9.0 for t.try support
  • (2) fast-check@^2.0.0 for hybrid module support: commonjs and esm together
  • (3) ava@>=0.1.0 for its Promise support
  • (4) Already compatible with fast-check@^3.0.0 but bump to 6.0.0 for updated peer version
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].