{"id":20252451,"url":"https://github.com/ivandotv/vitest-database-containers","last_synced_at":"2025-09-22T09:30:46.921Z","repository":{"id":226281824,"uuid":"668842669","full_name":"ivandotv/vitest-database-containers","owner":"ivandotv","description":"Example repository that demonstrates how to test MongoDB and PostgreSQL databases with Docker containers and Jest. ","archived":false,"fork":false,"pushed_at":"2024-11-23T05:30:06.000Z","size":228,"stargazers_count":3,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-23T06:20:44.435Z","etag":null,"topics":["docker","mongodb","nodejs","postgresql","vitest"],"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/ivandotv.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":"2023-07-20T18:04:36.000Z","updated_at":"2024-11-07T14:31:08.000Z","dependencies_parsed_at":"2024-11-23T06:19:56.036Z","dependency_job_id":"c079a15d-1b45-44c6-aa6b-86f0da7c6c7a","html_url":"https://github.com/ivandotv/vitest-database-containers","commit_stats":null,"previous_names":["ivandotv/vitest-database-containers"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fvitest-database-containers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fvitest-database-containers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fvitest-database-containers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fvitest-database-containers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivandotv","download_url":"https://codeload.github.com/ivandotv/vitest-database-containers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233837050,"owners_count":18737907,"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":["docker","mongodb","nodejs","postgresql","vitest"],"created_at":"2024-11-14T10:16:52.564Z","updated_at":"2025-09-22T09:30:41.521Z","avatar_url":"https://github.com/ivandotv.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MongoDB and PostgreSQL database testing with vitest and Docker containers\n\nThis is an example repository that demonstrates how to test MongoDB and PostgreSQL databases with Docker containers\nusing Vitest.\n\n## How it works\n\nWhen Vitest is started, and before the tests are executed, we create two docker database containers (MongoDB and PostgreSQL) each test file (Vitest Worker) gets a new database inside the container.\nIf the detected OS is Linux, we use the `tmpfs` file system inside the containers which increases the speed of execution since in that case all database data is held in memory.\n\n### Test execution\n\n- Before each test, the database is seeded.\n- After each test, the database is cleared.\n- When all tests in the file are done, the database is discarded.\n- When Vitest is done running all the tests, database containers are stopped and removed.\n\nVitest **watch** mode is supported, in that case, everything works that same, but database containers will not be stopped and removed until you exit _watch_ mode.\n\n### Running on Github Actions\n\nGithub actions file is included. Default Ubuntu Github Actions image comes with Docker preinstalled so there are no issues running the tests in a continuous integration environment.\n\n## Blog post\n\nI will eventually write a blog post detailing the whole setup process. You can follow me on [Twitter](https://twitter.com/iki_xx) or on [Dev.to](https://dev.to/ivandotv)\nto be notified of new blog posts.\n\nI use this setup in my projects, so this repository will be kept up to date.\n\nIf you have suggestions on how this process could be improved, feel free to open an issue or pull a request.\n\nThere is also a Jest setup, but I'm not maintaining that one anymore.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivandotv%2Fvitest-database-containers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivandotv%2Fvitest-database-containers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivandotv%2Fvitest-database-containers/lists"}