{
  "id": 15408335,
  "title": "Integration testing with PostgreSQL, Drizzle and Vitest",
  "url": "https://urgent.news/2026/10/18/integration-testing-with-postgresql-drizzle-and-vitest",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-18T12:42:01.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/dyedwiper/integration-testing-with-postgresql-drizzle-and-vitest-246l"
  },
  "original_language": "en",
  "account": "For a new TypeScript project, the author needed to devise a method for integration testing. It was agreed that PostgreSQL, Drizzle, and Vitest would be used as the technologies. The challenge was to set up a database for the tests to run on. The author found an article on testing Node.js and PostgreSQL applications with Drizzle and PGlite, but was unsatisfied with the performance of PGlite. The article also mentioned Testcontainers but discouraged it due to the overhead of creating throwaway containers. The author then came across an idea of creating throwaway databases in a running PostgreSQL instance, which they followed.\n\nFour approaches were implemented for this purpose:\n1. Using PGlite for creating a database for each test file\n2. Creating throwaway databases in a running PostgreSQL instance using three different methods\n3. Using Testcontainers (discouraged)\n4. Using Pglite (preferred)\n\nThe author implemented the POCs in a GitHub repository and added unit tests to distinguish them from integration tests. The integration tests ensure that the database is correctly cleaned up between tests. The four approaches are implemented in the repository's ddd folder and branches int-tests-*.\n\nGeneral notes on the usage of Vitest and Drizzle include the use of setupFiles and globalSetup, as well as the use of a function from drizzle-kit to push the schema programmatically. The tests include both integration and unit tests, and ensure that the database is properly cleaned up after each test.",
  "summary": "For a new TypeScript project I recently had to come up with a concept for integration testing. It was already decided that we will use the following technologies: PostgreSQL as database Drizzle as ORM framework Vitest as testing framework The main question was how to setup a database on which the tests can run. I didn't find much on the topic but the article How to Test Your Node.js & Postgres…",
  "key_points": [
    "Integration testing with PostgreSQL, Drizzle, and Vitest",
    "Four approaches implemented for creating throwaway databases",
    "Integration tests ensure proper database cleanup between tests"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}