{"id":26108,"library":"prisma-test-utils","title":"Prisma Test Utils","description":"A testing utility library for Prisma (formerly Prisma 2) that generates seed data and database pool management based on your Prisma schema. Version 0.4.1 (latest) is the current stable release, with sparse updates since 2020. The project is temporarily unmaintained as noted in the README. Key features include automatic seed data generation with customizable factories, isolated per-test databases via connection pooling, and full TypeScript type safety. Differentiates from manual seeding by being data-model agnostic and automatically adapting to schema changes. Requires peer dependencies @prisma/client, @prisma/lift, and prisma2, though these are now outdated as Prisma has evolved significantly (Prisma 4+).","status":"deprecated","version":"0.4.1","language":"javascript","source_language":"en","source_url":"https://github.com/prisma/prisma-test-utils","tags":["javascript","typescript"],"install":[{"cmd":"npm install prisma-test-utils","lang":"bash","label":"npm"},{"cmd":"yarn add prisma-test-utils","lang":"bash","label":"yarn"},{"cmd":"pnpm add prisma-test-utils","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime peer dependency for database client operations","package":"@prisma/client","optional":false},{"reason":"Peer dependency for database migrations (outdated, replaced by @prisma/migrate in newer Prisma)","package":"@prisma/lift","optional":false},{"reason":"Peer dependency for Prisma CLI (outdated, replaced by prisma in newer versions)","package":"prisma2","optional":false},{"reason":"Added as regular dependency in v0.4.1 for generator functionality","package":"@prisma/generator-helper","optional":false}],"imports":[{"note":"Default import from generated path, not from the npm package directly. Path depends on generator output configuration.","wrong":"import { seed } from 'prisma-test-utils'","symbol":"seed","correct":"import seed from '@generated/prisma-test-utils/seed'"},{"note":"Default import of pool class, also available as named export Pool. Path is generated, typically under node_modules/@generated.","wrong":"const { SQLitePool } = require('prisma-test-utils')","symbol":"SQLitePool","correct":"import SQLitePool from '@generated/prisma-test-utils'"},{"note":"Named export for the base Pool class. Available as both default and named export.","wrong":"const Pool = require('prisma-test-utils')","symbol":"Pool","correct":"import { Pool } from '@generated/prisma-test-utils'"}],"quickstart":{"code":"// schema.prisma\ngenerator testutils {\n  provider = \"prisma-test-utils\"\n  output   = \"node_modules/@generated/prisma-test-utils\"\n}\n\n// test.ts\nimport Photon from '@generated/photon'\nimport seed from '@generated/prisma-test-utils/seed'\n\nasync function run() {\n  const client = new Photon({ datasources: { db: { url: 'file:./dev.db' } } })\n  await seed(client, bag => ({\n    Post: {\n      amount: 10,\n      factory: {\n        title: bag.faker.sentence,\n        published: true,\n      },\n    },\n  }))\n  const posts = await client.posts.findMany()\n  console.log(posts.length) // 10\n  await client.$disconnect()\n}\nrun().catch(console.error)","lang":"typescript","description":"Configures the generator, seeds 10 Post records with faker-generated titles, and queries them using the Prisma client."},"warnings":[{"fix":"Consider using prisma/seed or custom seed scripts with Prisma 4+. Also explore alternatives like jest-prisma or prisma-seed.","message":"This project is temporarily unmaintained and uses outdated Prisma v2 APIs","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Use Prisma 2.x (prisma2) for compatibility. Cannot be used with Prisma 3+ without modifications.","message":"Peer dependency requirements include prisma2, @prisma/lift, and @prisma/client, all of which are outdated","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Ensure generator output path matches your import path exactly. Use tsconfig paths or jest moduleNameMapper as needed.","message":"Generated imports rely on specific output path (e.g., node_modules/@generated/prisma-test-utils) and won't work if generator config changes","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Type the bag parameter explicitly: (bag: any) => ({...}) or use generated types if available.","message":"The seed factory function uses kit (bag) parameter that provides faker.js and must be typed as any or manually typed","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use transaction rollback or isolated Prisma datamodels per test instead of database pooling.","message":"Pool classes (SQLitePool, etc.) are no longer necessary with modern Prisma testing strategies","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'prisma generate' after adding generator testutils to schema.prisma. Verify output path matches your imports.","cause":"Missing prisma generate step or incorrect generator output path","error":"Cannot find module '@generated/prisma-test-utils' or '@generated/prisma-test-utils/seed'"},{"fix":"Use default import: import seed from '@generated/prisma-test-utils/seed'","cause":"Incorrect import (named instead of default) or missing generated module","error":"TypeError: seed is not a function"},{"fix":"Install all peer deps: npm install @prisma/client @prisma/lift prisma2","cause":"Missing peer dependency @prisma/lift","error":"Error: Cannot find module '@prisma/lift'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}