Property Testing
Property-based testing with fast-check for business logic validation
Best use case
Property Testing is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Property-based testing with fast-check for business logic validation
Teams using Property Testing should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/property-testing-majiayu000/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How Property Testing Compares
| Feature / Agent | Property Testing | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Property-based testing with fast-check for business logic validation
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Property Testing
LivestockAI uses property-based testing (PBT) with fast-check to validate business logic invariants.
## What is Property Testing?
Instead of testing specific examples, property tests verify that properties hold for ALL possible inputs:
```typescript
// Example-based test
it('calculates FCR correctly', () => {
expect(calculateFCR(150, 100)).toBe(1.5)
})
// Property-based test
it('FCR is always positive when inputs are positive', () => {
fc.assert(
fc.property(
fc.float({ min: 0.1, max: 10000 }),
fc.float({ min: 0.1, max: 10000 }),
(feed, weight) => {
const fcr = calculateFCR(feed, weight)
return fcr === null || fcr > 0
},
),
)
})
```
## fast-check Basics
```typescript
import { describe, it, expect } from 'vitest'
import * as fc from 'fast-check'
describe('Property Tests', () => {
it('property holds for all inputs', () => {
fc.assert(
fc.property(fc.integer({ min: 1, max: 100000 }), (quantity) => {
// Property must return true or throw
return quantity > 0
}),
{ numRuns: 100 },
)
})
})
```
## Common Arbitraries
```typescript
// Integers
fc.integer({ min: 1, max: 100000 })
fc.nat() // Non-negative integer
// Floats
fc.float({ min: 0, max: 10000 })
// Strings
fc.string()
fc.uuid()
// Arrays
fc.array(fc.integer(), { minLength: 0, maxLength: 20 })
// Objects
fc.record({
quantity: fc.integer({ min: 1, max: 1000 }),
price: fc.float({ min: 0, max: 10000 }),
})
```
## Inventory Invariant Example
From `tests/features/batches/batches.property.test.ts`:
```typescript
/**
* Property 4: Inventory Invariant
* For any batch, current_quantity SHALL always equal:
* initial_quantity - sum(mortality) - sum(sales)
*/
describe('Property 4: Inventory Invariant', () => {
it('current_quantity equals initial - mortalities - sales', () => {
fc.assert(
fc.property(
fc.integer({ min: 1, max: 100000 }),
fc.array(fc.integer({ min: 1, max: 1000 })),
fc.array(fc.integer({ min: 1, max: 1000 })),
(initial, mortalities, sales) => {
const { constrained } = constrainQuantities(
initial,
mortalities,
sales,
)
const current = calculateCurrentQuantity(initial, constrained)
expect(current).toBeGreaterThanOrEqual(0)
expect(current).toBeLessThanOrEqual(initial)
},
),
{ numRuns: 100 },
)
})
})
```
## Linking to Requirements
Annotate tests with requirement links:
```typescript
/**
* **Validates: Requirements 3.2, 4.2, 8.2**
*/
it('inventory invariant holds', () => {
// ...
})
```
## When to Use Property Testing
- Mathematical calculations (FCR, mortality rate, profit)
- Invariants (quantity never negative, totals match)
- State transitions (batch status changes)
- Data transformations (currency conversion)
## Related Skills
- `vitest-patterns` - Unit testing basics
- `three-layer-architecture` - Service layer testingRelated Skills
qa-testing
Ensure data integrity, stability, and basic security for a personal productivity app. Focus on preventing data loss, memory leaks, and sync failures during daily 8-hour usage sessions. Skip enterprise-grade testing. Use when testing, verifying, validating, checking features, running tests, or before claiming anything is "done" or "fixed".
qa-testing-strategy
Risk-based quality engineering test strategy across unit, integration, contract, E2E, performance, and security testing with shift-left gates, flake control, CI economics, and observability-first debugging.
qa-testing-playwright
End-to-end web application testing with Playwright: scope control, stable selectors, parallelization/sharding, flake control, network mocking vs real services, visual testing tradeoffs, and CI/CD integration.
qa-testing-ios
iOS testing with XCTest/XCUITest on simulators and devices: layered strategy, determinism/flake control, device matrix selection, CI ergonomics, and repeatable simulator automation.
Playwright E2E Testing
Comprehensive Playwright end-to-end testing patterns with Page Object Model, fixtures, and best practices
OWASP Security Testing
OWASP Top 10 security testing patterns and vulnerability scanning
mobile-testing
Executes automated tests on mobile apps via MCP. Use when testing iOS/Android apps, verifying UI states, automating interactions, or performing end-to-end validation. Not for web testing, API validation, or desktop applications.
moai-workflow-testing
AI-powered enterprise web application testing orchestrator with Context7 integration, intelligent test generation, visual regression testing, cross-browser coordination, and automated QA workflows for modern web applications
midnight-dapp:testing-patterns
Use when writing unit tests for Midnight contract interaction code, integration testing without ZK proofs, E2E testing with Playwright or Cypress, or setting up CI/CD pipelines for Midnight DApps.
implementing-e2e-testing
Master end-to-end testing with Playwright and Cypress to build reliable test suites that catch bugs, improve confidence, and enable fast deployment. Use when implementing E2E tests, debugging flaky tests, or establishing testing standards.
idor-testing
This skill should be used when the user asks to "test for insecure direct object references," "find IDOR vulnerabilities," "exploit broken access control," "enumerate user IDs or obje...
File Path Traversal Testing
This skill should be used when the user asks to "test for directory traversal", "exploit path traversal vulnerabilities", "read arbitrary files through web applications", "find LFI vulnerabilities", or "access files outside web root". It provides comprehensive file path traversal attack and testing methodologies.