nw-pbt-typescript

Solid

TypeScript/JavaScript property-based testing with fast-check framework and arbitraries

Testing & QA 526 stars 55 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 95/100

Stars 20%
91
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# PBT TypeScript -- fast-check ## Framework Selection **fast-check** is the dominant PBT framework for TypeScript/JavaScript. No serious competitors. - 8+ years mature, very actively maintained - First-class TypeScript types - Zero runtime dependencies - Used by jest, jasmine, fp-ts, ramda, js-yaml ## Quick Start ```typescript import fc from 'fast-check'; test('sort is idempotent', () => { fc.assert( fc.property(fc.array(fc.integer()), (arr) => { const sorted = [...arr].sort((a, b) => a - b); const twice = [...sorted].sort((a, b) => a - b); expect(sorted).toEqual(twice); }), { numRuns: 1000 } ); }); ``` ## Generator (Arbitrary) Cheat Sheet ### Primitives ```typescript fc.integer() // any safe integer fc.integer({ min: 0, max: 99 }) fc.nat() // non-negative integer fc.float() fc.double() fc.string() fc.string({ minLength: 1, maxLength: 50 }) fc.boolean() fc.constant(null) fc.constantFrom(1, 2, 3) // pick from values ``` ### Collections ```typescript fc.array(fc.integer()) fc.array(fc.integer(), { minLength: 1, maxLength: 10 }) fc.set(fc.integer()) fc.dictionary(fc.string(), fc.integer()) fc.tuple(fc.integer(), fc.string()) ``` ### Combinators ```typescript fc.oneof(fc.integer(), fc.string()) // union fc.option(fc.integer()) // T | null // Map fc.integer().map(n => n * 2) // even integers // Filter fc.integer().filter(n => n > 0) // Prefer: fc...

Details

Author
nWave-ai
Repository
nWave-ai/nWave
Created
3 months ago
Last Updated
1 weeks ago
Language
Python
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category