Socket
Book a DemoInstallSign in
Socket

@fast-check/jest

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fast-check/jest

Property based testing for Jest based on fast-check

2.1.1
latest
Source
npmnpm
Version published
Weekly downloads
160K
1.93%
Maintainers
1
Weekly downloads
 
Created

What is @fast-check/jest?

@fast-check/jest is a package that integrates fast-check, a property-based testing library, with Jest, a popular JavaScript testing framework. It allows developers to write tests that automatically generate a wide range of inputs to ensure code behaves correctly under various conditions.

What are @fast-check/jest's main functionalities?

Property-based Testing

This feature allows you to define properties that your code should satisfy for a wide range of automatically generated inputs. The code sample demonstrates a simple property-based test that checks if the absolute value of any integer is always non-negative.

const { testProp, fc } = require('@fast-check/jest');

testProp('should always return a positive number', [fc.integer()], (n) => {
  expect(Math.abs(n)).toBeGreaterThanOrEqual(0);
});

Custom Arbitraries

This feature allows you to create custom arbitraries, which are generators for your test inputs. The code sample shows how to create a custom arbitrary that generates tuples of integers and strings, and then tests a property using these tuples.

const { testProp, fc } = require('@fast-check/jest');

const customArbitrary = fc.tuple(fc.integer(), fc.string());

testProp('should handle custom arbitrary', [customArbitrary], ([num, str]) => {
  expect(typeof num).toBe('number');
  expect(typeof str).toBe('string');
});

Other packages similar to @fast-check/jest

Keywords

jest

FAQs

Package last updated on 28 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.