All Projects → ctrlplusb → prisma-pg-jest

ctrlplusb / prisma-pg-jest

Licence: other
Example showcasing how to use Prisma + Postgres + Jest, where each test has its own unique DB context

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to prisma-pg-jest

blitz
⚡️The Fullstack React Framework — built on Next.js
Stars: ✭ 11,558 (+11121.36%)
Mutual labels:  prisma, prisma2
prisma-json-schema-generator
A generator for Prisma 2 to generate a valid JSON Schema (v7)
Stars: ✭ 145 (+40.78%)
Mutual labels:  prisma, prisma2
nestjs-prisma-starter
Starter template for NestJS 😻 includes GraphQL with Prisma Client, Passport-JWT authentication, Swagger Api and Docker
Stars: ✭ 1,107 (+974.76%)
Mutual labels:  prisma, prisma2
database-schema-examples
Database Schema Examples we strive to support in Prisma
Stars: ✭ 94 (-8.74%)
Mutual labels:  prisma, prisma2
nestjs-prisma-docker
Dockerizing a NestJS app with Prisma and PostgreSQL
Stars: ✭ 42 (-59.22%)
Mutual labels:  prisma, prisma2
nest-prisma-rest-api-boilerplate
Nest + Prisma + TypeScript | REST API Starter repository
Stars: ✭ 24 (-76.7%)
Mutual labels:  prisma, prisma2
goprisma
A Go wrapper for prisma to turn databases into GraphQL APIs using Go.
Stars: ✭ 54 (-47.57%)
Mutual labels:  prisma, prisma2
Real World Grading App
An example of a real-world REST API backend built with TypeScript, Hapi, Prisma, and PostgreSQL.
Stars: ✭ 105 (+1.94%)
Mutual labels:  prisma
Prisma Auth0 Example
Boilerplate Prisma Startup
Stars: ✭ 184 (+78.64%)
Mutual labels:  prisma
Production Ready Expressjs Server
Express.js server that implements production-ready error handling and logging following latest best practices.
Stars: ✭ 101 (-1.94%)
Mutual labels:  prisma
Prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite & MongoDB (Preview)
Stars: ✭ 18,168 (+17538.83%)
Mutual labels:  prisma
Ledokku
Beautiful web UI for all things Dokku
Stars: ✭ 103 (+0%)
Mutual labels:  prisma
Prisma Multi Tenant
🧭 Use Prisma as a multi-tenant provider for your application
Stars: ✭ 187 (+81.55%)
Mutual labels:  prisma
Nestjs Realworld Example App
Exemplary real world backend API built with NestJS + TypeORM / Prisma
Stars: ✭ 1,838 (+1684.47%)
Mutual labels:  prisma
Prisma Ecommerce
💰A graphql e-commerce real-world fullstack example (backoffice included)
Stars: ✭ 231 (+124.27%)
Mutual labels:  prisma
Prisma Docs Generator
Prisma generator for automatically generating documentation reference from the Prisma schema.
Stars: ✭ 91 (-11.65%)
Mutual labels:  prisma
Prisma Tools
Prisma tools to help you generate CRUD system for GraphQL servers
Stars: ✭ 237 (+130.1%)
Mutual labels:  prisma
Canner
⚡️[NOT MAINTAINED] Content Management Framework creates custom CMS fast and easy. Support data sources such as Firebase/Firestore, GraphQL and Restful APIs.
Stars: ✭ 2,472 (+2300%)
Mutual labels:  prisma
Ra Data Opencrud
A react-admin data provider for Prisma and GraphCMS
Stars: ✭ 142 (+37.86%)
Mutual labels:  prisma
Typegraphql Prisma
Prisma 2 generator to emit TypeGraphQL types and CRUD resolvers from your Prisma 2 schema
Stars: ✭ 137 (+33.01%)
Mutual labels:  prisma

Prisma + Postgres + Jest

This example showcases how you can configure your Jest environment in order to perform integration tests against applications utilising Prisma and Postgres.

Each test suite will create a temporary schema within the database, allowing concurrent execution of them. The temporary schema is subsequently cleaned up after each test suite has completed.

Setup

Clone the repo.

git clone https://github.com/ctrlplusb/prisma-pg-jest

Install the dependencies.

cd prisma-pg-jest
npm install

Running the database

A docker-compose.yml file has been created to represent the Postgres database that we will use for local development.

You will need Docker installed.

To start the database run the following command:

npm run db:start

Once you are finished developing you can stop the db by running the following command:

npm run db:stop

This project has been configured to run with the following Postgres configuration. You can modify these to suit your needs by editing the docker-compose.yml file.

- HOST=localhost
- PORT=54320
- POSTGRES_USER=prisma
- POSTGRES_PASSWORD=hilly-sand-pit
- POSTGRES_DB=prisma

Jest Configuration

We have configured Jest to execute with a custom test environment. See the `prisma/prisma-test-environment.js file for more details.

This custom environment ensures that each test suite getting executed will have a unique schema created for them against the running Postgres database. The migrations will then be executed against them, via the prisma migrate up --experimental command, ensuring that the latest model has been applied to the schema.

Running your tests

Ensure that your local Postgres is running.

npm run db:start

Then execute the Jest tests via the following command:

npm run test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].