Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Prisma
  3. Prismock - Run tests in isolation with an in-memory implementation of Prisma

Prismock - Run tests in isolation with an in-memory implementation of Prisma

MITTypeScriptv1.35.4

A mock for PrismaClient that reads your Prisma schema and provides an in-memory store for fast, isolated unit tests.

Visit WebsiteGitHubGitHub
267 stars34 forks0 contributors

What is Prismock - Run tests in isolation with an in-memory implementation of Prisma?

Prismock is a mocking library for PrismaClient that reads your Prisma schema and provides an in-memory implementation for unit testing. It simulates Prisma's API to allow developers to write fast, isolated tests without needing a live database connection. The library is extensively tested against real Prisma results to ensure accuracy across MySQL, PostgreSQL, and MongoDB environments.

Target Audience

Developers using Prisma ORM who need to write unit tests for their applications without relying on a live database. It is particularly useful for backend engineers, full-stack developers, and educators teaching testing practices with Prisma.

Value Proposition

Prismock offers a schema-aware, in-memory mock that closely replicates Prisma's behavior, enabling reliable and fast unit tests. Unlike generic mocks, it reads your actual Prisma schema, supports most Prisma features, and is validated against real database results, reducing test flakiness and integration complexity.

Overview

A mock for PrismaClient, dedicated to unit testing.

Use Cases

Best For

  • Unit testing Prisma-based applications without a live database
  • Creating isolated test environments for CI/CD pipelines
  • Testing Prisma queries and relationships in memory
  • Educational purposes for teaching backend testing with Prisma
  • Prototyping applications with an in-memory Prisma implementation
  • Ensuring test retry-ability by avoiding external database dependencies

Not Ideal For

  • Applications relying heavily on JSON field queries or scalar list filters
  • Integration testing requiring real database transactions and persistence
  • Production use cases where data must survive beyond in-memory sessions

Pros & Cons

Pros

Schema-Aware Accuracy

Reads your actual Prisma schema to generate models and relationships, ensuring the mock closely mirrors your database structure for reliable testing.

Comprehensive API Simulation

Supports most Prisma query methods, filters, and nested operations, with validation against real Prisma results across MySQL, PostgreSQL, and MongoDB.

Easy Test Integration

Offers seamless setup with Jest and ViTest via automatic mocking or manual instantiation, fitting smoothly into existing testing workflows.

Fast In-Memory Execution

Stores data in-memory for rapid, isolated test runs without external database dependencies, ideal for CI/CD pipelines and retry-able tests.

Cross-Environment Validation

Tested against real Prisma outcomes for multiple databases, increasing confidence in mock reliability and reducing test flakiness.

Cons

Incomplete Feature Coverage

Lacks support for key Prisma features like JSON filters, scalar list methods, and some nested operations (e.g., set, disconnect), which can break tests for complex schemas.

Setup Complexity for Custom Paths

Requires additional configuration via createPrismock for custom Prisma client output paths, adding overhead compared to standard setups.

Partial Advanced Query Support

GroupBy queries have limitations such as no skip, take, or cursor support, and referential actions like onUpdate are unsupported, restricting certain testing scenarios.

Potential Behavioral Gaps

As a mock, it may not perfectly replicate all edge cases of real Prisma behavior, necessitating manual verification for critical or unsupported queries.

Frequently Asked Questions

Quick Stats

Stars267
Forks34
Contributors0
Open Issues22
Last commit21 hours ago
CreatedSince 2022

Tags

#unit-testing#prisma#vitest#backend-testing#typescript#testing#mock#in-memory-database#jest

Built With

P
Prisma
T
TypeScript

Links & Resources

Website

Included in

Prisma655
Auto-fetched 11 hours ago

Related Projects

Documentation GeneratorDocumentation Generator

Prisma generator for automatically generating documentation reference from the Prisma schema.

Stars625
Forks31
Last commit2 years ago
Schemix - Generate Prisma Schemas with TypeScriptSchemix - Generate Prisma Schemas with TypeScript

Schemix allows you to programmatically create Prisma schemas using TypeScript ⌨️

Stars480
Forks24
Last commit2 years ago
Multi-tenancy with PrismaMulti-tenancy with Prisma

🧭 Use Prisma as a multi-tenant provider for your application

Stars400
Forks42
Last commit3 years ago
Prisma Redis Middleware - cache queries in RedisPrisma Redis Middleware - cache queries in Redis

Prisma Middleware for caching queries in Redis

Stars362
Forks34
Last commit7 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub