{"id":28558482,"url":"https://github.com/shelfio/jest-postgres","last_synced_at":"2025-08-03T17:37:01.214Z","repository":{"id":65071960,"uuid":"581201158","full_name":"shelfio/jest-postgres","owner":"shelfio","description":"Jest preset for running tests with local Postgres","archived":false,"fork":false,"pushed_at":"2024-08-27T14:12:58.000Z","size":79,"stargazers_count":11,"open_issues_count":2,"forks_count":1,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-06-03T05:51:55.838Z","etag":null,"topics":["jest","jest-postgres","jest-tests","postgresql","test"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shelfio.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-22T14:40:20.000Z","updated_at":"2025-02-06T10:24:42.000Z","dependencies_parsed_at":"2023-12-21T02:37:24.845Z","dependency_job_id":"9cc8b9d2-a5dd-42ba-971a-bcc628d023b7","html_url":"https://github.com/shelfio/jest-postgres","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shelfio%2Fjest-postgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shelfio%2Fjest-postgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shelfio%2Fjest-postgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shelfio%2Fjest-postgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shelfio","download_url":"https://codeload.github.com/shelfio/jest-postgres/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shelfio%2Fjest-postgres/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259033839,"owners_count":22795772,"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":["jest","jest-postgres","jest-tests","postgresql","test"],"created_at":"2025-06-10T08:08:59.260Z","updated_at":"2025-06-10T08:08:59.356Z","avatar_url":"https://github.com/shelfio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jest-postgres [![CircleCI](https://circleci.com/gh/shelfio/jest-postgres/tree/master.svg?style=svg)](https://circleci.com/gh/shelfio/jest-postgres/tree/master) ![](https://img.shields.io/badge/code_style-prettier-ff69b4.svg) [![npm (scoped)](https://img.shields.io/npm/v/@shelf/jest-postgres.svg)](https://www.npmjs.com/package/@shelf/jest-postgres)\n\n\u003e Jest preset to run Postgres server\n\n[Test Postgres using only this jest plugin (no DB mocks/Docker)!](https://medium.com/shelf-io-engineering/test-postgres-using-jest-755389b28d22)\n\n## Usage\n\n### 0. Install\n\n```\n$ yarn add @shelf/jest-postgres --dev\n```\n\n### 1. Create `jest.config.js`\n\n```js\nmodule.exports = {\n  preset: '@shelf/jest-postgres',\n};\n```\n\nIf you have a custom `jest.config.js` make sure you remove `testEnvironment` property, otherwise it will conflict with the preset.\n\n### 2. Create `jest-postgres-config.js`\n\n```js\nimport cwd from 'cwd';\n\nmodule.exports = {\n  seedPath: `${cwd()}/test/seed.sql`,\n  version: 14,\n  port: 5555,\n};\n```\n\nFind `seed.sql` example in `./test` folder of this repo, view [postgres-local](https://github.com/shelfio/postgres-local#1-start-postgres) for more params.\n\n### 4. PROFIT! Write tests\n\n```js\nit();\n```\n\n## Monorepo Support\n\nBy default the `jest-postgres-config.js` is read from `cwd` directory, but this might not be\nsuitable for monorepos with nested [jest projects](https://jestjs.io/docs/configuration#projects-arraystring--projectconfig)\nwith nested `jest.config.*` files nested in subdirectories.\n\nIf your `jest-postgres-config.js` file is not located at `{cwd}/jest-postgres-config.js` or you\nare using nested `jest projects`, you can define the environment variable `JEST_POSTGRES_CONFIG`\nwith the absolute path of the respective `jest-postgres-config.js` file.\n\n### Example Using `JEST_POSTGRES_CONFIG` in nested project\n\n```js\n// src/nested/project/jest.config.js\nconst path = require('path');\n\n// Define path of project level config - extension not required as file will be imported\n// via `require(process.env.JEST_POSTGRES_CONFIG)`\nprocess.env.JEST_POSTGRES_CONFIG = path.resolve(__dirname, './jest-postgres-config');\n\nmodule.exports = {\n  preset: '@shelf/jest-postgres'\n  displayName: 'nested-project',\n};\n```\n\n## See Also\n\n- [postgres-local](https://github.com/shelfio/postgres-local)\n- [jest-elasticsearch](https://github.com/shelfio/jest-elasticsearch)\n- [jest-dynamodb](https://github.com/shelfio/jest-dynamodb)\n\n## Publish\n\n```sh\n$ git checkout master\n$ yarn version\n$ yarn publish\n$ git push origin master --tags\n```\n\n## License\n\nMIT © [Shelf](https://shelf.io)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshelfio%2Fjest-postgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshelfio%2Fjest-postgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshelfio%2Fjest-postgres/lists"}