Skip to content

Set up Vitest for unit testing#49

Open
FluxCapacitor2 wants to merge 7 commits intoconstructor-dependency-injectionfrom
unit-tests
Open

Set up Vitest for unit testing#49
FluxCapacitor2 wants to merge 7 commits intoconstructor-dependency-injectionfrom
unit-tests

Conversation

@FluxCapacitor2
Copy link
Copy Markdown
Collaborator

@FluxCapacitor2 FluxCapacitor2 commented Apr 14, 2026

This PR adds Vitest for unit testing and a GitHub Actions workflow that runs tests when files in the backend folder change.

Tests have access to a createDB function that uses pglite to create an in-memory Postgres database. That way, each test has its own isolated database that doesn't leave behind files or require a separate process.

While setting up the tests, I realized importing env.ts causes the side effect of validating the environment variables, which will make any test fail. To address this, I moved environment variables to properties/constructor parameters of the service classes that they're in, so all accesses to env now happen within service/index.ts.

So far, I just added one test that makes sure the test DB works properly - I'm not testing any actual functionality yet, but this PR is the first step. We should discuss which parts are most important to test and start there. I'm thinking createApp(Group), updateApp, githubWebhook, auth, updateDeployment, githubOAuthCallback, and githubInstallCallback are the most important/likely to break.

@FluxCapacitor2 FluxCapacitor2 changed the title Unit tests Set up Vitest for unit testing Apr 14, 2026
@FluxCapacitor2 FluxCapacitor2 marked this pull request as ready for review April 15, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant