{"id":13485202,"url":"https://github.com/ctrlplusb/prisma-pg-jest","last_synced_at":"2025-04-14T22:37:21.306Z","repository":{"id":40795459,"uuid":"226000789","full_name":"ctrlplusb/prisma-pg-jest","owner":"ctrlplusb","description":"Example showcasing how to use Prisma + Postgres + Jest, where each test has its own unique DB context","archived":false,"fork":false,"pushed_at":"2023-01-06T02:19:34.000Z","size":922,"stargazers_count":102,"open_issues_count":13,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T10:50:19.541Z","etag":null,"topics":["example","jest","postgres","prisma","prisma2"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ctrlplusb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-05T02:40:39.000Z","updated_at":"2025-03-25T19:29:58.000Z","dependencies_parsed_at":"2023-02-05T02:45:53.707Z","dependency_job_id":null,"html_url":"https://github.com/ctrlplusb/prisma-pg-jest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrlplusb%2Fprisma-pg-jest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrlplusb%2Fprisma-pg-jest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrlplusb%2Fprisma-pg-jest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrlplusb%2Fprisma-pg-jest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ctrlplusb","download_url":"https://codeload.github.com/ctrlplusb/prisma-pg-jest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248974684,"owners_count":21192186,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["example","jest","postgres","prisma","prisma2"],"created_at":"2024-07-31T17:01:50.582Z","updated_at":"2025-04-14T22:37:21.281Z","avatar_url":"https://github.com/ctrlplusb.png","language":"TypeScript","readme":"# Prisma + Postgres + Jest\n\nThis example showcases how you can configure your Jest environment in order to perform integration tests against applications utilising Prisma and Postgres.\n\nEach 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.\n\n## Setup\n\nClone the repo.\n\n```bash\ngit clone https://github.com/ctrlplusb/prisma-pg-jest\n```\n\nInstall the dependencies.\n\n```bash\ncd prisma-pg-jest\nnpm install\n```\n\n## Running the database\n\nA `docker-compose.yml` file has been created to represent the Postgres database that we will use for local development.\n\nYou will need [Docker](https://docs.docker.com/v17.09/engine/installation/) installed.\n\nTo start the database run the following command:\n\n```bash\nnpm run db:start\n```\n\nOnce you are finished developing you can stop the db by running the following command:\n\n```bash\nnpm run db:stop\n```\n\nThis 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`](docker-compose.yml) file.\n\n```\n- HOST=localhost\n- PORT=54320\n- POSTGRES_USER=prisma\n- POSTGRES_PASSWORD=hilly-sand-pit\n- POSTGRES_DB=prisma\n```\n\n## Jest Configuration\n\nWe have configured Jest to execute with a custom test environment. See the [`prisma/prisma-test-environment.js](prisma/prisma-test-environment.js) file for more details.\n\nThis 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.\n\n## Running your tests\n\nEnsure that your local Postgres is running.\n\n```bash\nnpm run db:start\n```\n\nThen execute the Jest tests via the following command:\n\n```bash\nnpm run test\n```\n","funding_links":[],"categories":["TypeScript",":safety_vest: Community Prisma Tools"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctrlplusb%2Fprisma-pg-jest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fctrlplusb%2Fprisma-pg-jest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctrlplusb%2Fprisma-pg-jest/lists"}