nw-pbt-typescript
FeaturedTypeScript/JavaScript property-based testing with fast-check framework and arbitraries
Testing & QA 636 stars
68 forks Updated today MIT
Install
Quality Score: 98/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
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
- 9 months ago
- Last Updated
- today
- Language
- Python
- License
- MIT
Similar Skills
Semantically similar based on skill content — not just same category
Testing & QA Solid
property-based-testing
Property-based testing (PBT) patterns with fast-check (JS/TS), Hypothesis (Python), and gopter (Go). Generate random inputs, define invariants, shrink failures to minimal cases. Adapted from Trail of Bits. Use when testing pure functions, parsers, serializers, state machines, or any code where example-based tests miss edge cases.
552 Updated 6 days ago
vibeeval Testing & QA Listed
property-testing
Property-based testing with fast-check for business logic validation
6 Updated 9 months ago
captjay98 Testing & QA Featured
nw-pbt-dotnet
.NET property-based testing with FsCheck, CsCheck, and fsharp-hedgehog frameworks
636 Updated today
nWave-ai