Generating dummy entities with random data for tests based on types

This page summarizes the projects mentioned and recommended in the original post on /r/typescript

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • fishery

    A library for setting up JavaScript objects as test data

  • Is someone using that fishery lib?

  • fast-check

    Property based testing framework for JavaScript (like QuickCheck) written in TypeScript

  • The closest that I know of (and I have not used this) is zod-fast-check. It generates fast-check “arbitraries” (test data generators) for property-based testing based on zod schemas. Of course, this requires that you use zod to define your types, which has some downsides. Fortunately there is another tool, ts-to-zod, (which I also have not used) which will codegen zod schemas based on TS type definitions. If you thread these four libraries together you should end up with the ability to write random tests on generated data with very little overhead. In theory.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • ts-to-zod

    Generate zod schemas from typescript types/interfaces

  • The closest that I know of (and I have not used this) is zod-fast-check. It generates fast-check “arbitraries” (test data generators) for property-based testing based on zod schemas. Of course, this requires that you use zod to define your types, which has some downsides. Fortunately there is another tool, ts-to-zod, (which I also have not used) which will codegen zod schemas based on TS type definitions. If you thread these four libraries together you should end up with the ability to write random tests on generated data with very little overhead. In theory.

  • intermock

    Mocking library to create mock objects with fake data for TypeScript interfaces

  • I found Intermock a little while ago when I was looking for something similar. It looks relatively inactive, but I didn't even try it out or look into it any further.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts