Generating dummy entities with random data for tests based on types

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

Our great sponsors
  • Appwrite - The Open Source Firebase alternative introduces iOS support
  • Scout APM - Less time debugging, more time building
  • SonarQube - Static code analysis for 29 languages.
  • 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.

  • Appwrite

    Appwrite - The Open Source Firebase alternative introduces iOS support . Appwrite is an open source backend server that helps you build native iOS applications much faster with realtime APIs for authentication, databases, files storage, cloud functions and much more!

  • 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