{"repo":"chax-at/transactional-prisma-testing","free":true,"listed":false,"github":"https://github.com/chax-at/transactional-prisma-testing","clone":"git clone https://github.com/chax-at/transactional-prisma-testing.git","description":"Provides an easy way to execute database tests in a transaction that will be rolled back after each test for fast testing","language":"TypeScript","stars":53,"topics":["database","testing","transaction","postgres","postgresql","prisma","fast"],"license":"MIT","category":"databases-storage","readme_excerpt":"@chax-at/transactional-prisma-testing This package provides an easy way to run test cases inside a single database transaction that will be rolled back after each test. This allows fast test execution while still providing the same source database state for each test. It also allows parallel test execution against the same database. Prerequisites You are using Prisma 4.7.0 or later in your project. You are using PostgreSQL (other DBs might work but have not been tested). You are not using Fluent API. Usage Install the package by running Note that this will install the package as a dev dependency, intended to be used during tests only (remove the -D if you want to use it outside of tests). Example The following example for a NestJS project shows how this package can be used. It is however possible to use this package with every testing framework, just check out the documentation below and adapt the code accordingly. You can simply replace the PrismaService with PrismaClient if you are not using NestJS. PrismaTestingHelper The PrismaTestingHelper provides a proxy to the prisma client and manages this proxy. constructor(prismaClient: T) Create a single PrismaTestingHelper per test runner (or a single global one if tests are executed sequentially). The constructor parameter is the original PrismaClient that will be used to start transaction. Note that it is possible to use any objects that extend the PrismaClient, e.g. a NestJS PrismaService . All methods that don't exist on the ","default_branch":null,"files":null,"tree":[],"storefront":"/r/chax-at","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/chax-at/transactional-prisma-testing/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}