Prismock

screenshot of Prismock
prisma

A mock for PrismaClient, dedicated to unit testing.

Overview

Prismock is an innovative mock for PrismaClient that elevates the testing experience by reading your schema.prisma file and generating models dynamically. It allows developers to simulate Prisma's API with an in-memory solution that facilitates fast, isolated, and retry-able unit tests. This makes it an ideal tool for projects that require extensive testing across various environments such as MySQL, PostgreSQL, and MongoDB. The library's effectiveness stems not only from its design but also from its rigorous testing, where the results from the mock are carefully compared with actual query outputs from Prisma.

Using Prismock, developers can easily prototype their applications while enjoying an in-memory implementation of Prisma. It simplifies the setup for testing, providing a clear path to achieving reliable unit tests without the need for extensive database interactions. The utility is perfect for those who prioritize both performance and accuracy in their testing processes.

Features

  • Schema-Based Model Generation: Automatically reads from your schema.prisma and generates models, ensuring accuracy and reducing setup time.
  • In-Memory Storage: Stores data in memory for fast tests that are isolated and can be retried without dependency on external databases.
  • Compatibility: Supports multiple database environments including MySQL, PostgreSQL, and MongoDB, making it versatile for various applications.
  • Extensive Query Support: Offers support for a comprehensive range of model queries such as findUnique, create, delete, and more, covering most common use cases.
  • Custom Client Path Usage: Allows for custom client paths with the createPrismock method, providing flexibility in integrating into existing applications.
  • Additional Utility Functions: Includes getData and reset functions for edge-case scenarios requiring direct data management, although often unnecessary in standard use.
  • Nested Queries Support: Facilitates complex operations by supporting nested queries like createMany, update, and connect, enhancing testing scenarios.
  • Automatic Mocking Setup: Simplifies the mocking process with an easy setup, allowing automatic mocking of Prisma in your tests without extensive configuration.
prisma
Prisma

Prisma is a server-side library that helps developers read and write data to the database in an intuitive, efficient and safe way.

fullstack
Fullstack

A fullstack boilerplate provides a starter application that includes both frontend and backend. It should include database, auth, payments, user roles and other backend services to build a fully featured saas or webapps.

eslint
Eslint

ESLint is a linter for JavaScript that analyzes code to detect and report on potential problems and errors, as well as enforce consistent code style and best practices, helping developers to write cleaner, more maintainable code.

typescript
Typescript

TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.