Development
Set up the Pocket ID development environment, format the code, and run tests.
Follow the shared contribution guidelines before submitting a pull request.
Formatting
Section titled “Formatting”Run pnpm format from the repository root before submitting a pull request.
Development Environment
Section titled “Development Environment”Pocket ID consists of a frontend and backend. In production the frontend gets statically served by the backend, but in development they run as separate processes to enable hot reloading.
There are two ways to get the development environment setup:
1. Install required tools
Section titled “1. Install required tools”With Dev Containers
Section titled “With Dev Containers”If you use Dev Containers in VS Code, you don’t need to install anything manually, just follow the steps below.
- Make sure you have Dev Containers extension installed
- Clone and open the repo in VS Code
- VS Code will detect .devcontainer and will prompt you to open the folder in devcontainer
- If the auto prompt does not work, hit
F1and selectDev Containers: Open Folder in Container., then select the pocket-id repo root folder and it’ll open in container.
Without Dev Containers
Section titled “Without Dev Containers”If you don’t use Dev Containers, you need to install the following tools manually:
2. Setup
Section titled “2. Setup”Backend
Section titled “Backend”The backend is built with Gin and written in Go. To set it up, follow these steps:
- Open the
backendfolder - Copy the
.env.development-examplefile to.envand edit the variables as needed - Start the backend with
go run -tags exclude_frontend ./cmd
Frontend
Section titled “Frontend”The frontend is built with SvelteKit and written in TypeScript. To set it up, follow these steps:
- Open the
pocket-idproject folder - Copy the
frontend/.env.development-examplefile tofrontend/.envand edit the variables as needed - Install the dependencies with
pnpm install - Start the frontend with
pnpm dev
You’re all set! The application is now listening on localhost:3000. The backend gets proxied trough the frontend in development mode.
Testing
Section titled “Testing”If you are contributing to a new feature please ensure that you add tests for it.
End-to-end tests
Section titled “End-to-end tests”We are using Playwright for end-to-end testing.
The tests are located in the tests folder at the root of the project.
The tests can be run like this:
-
Install the dependencies from the root of the project
pnpm install -
Visit the setup folder by running
cd tests/setup -
Start the test environment by running
docker compose up -d --build -
Go back to the test folder by running
cd .. -
Run the tests with
pnpm dlx playwright testor from the root project folderpnpm test
If you make any changes to the application, you have to rebuild the test environment by running docker compose up -d --build again.
Unit tests
Section titled “Unit tests”In the backend we are using unit tests with the built-in Go testing framework. The tests are located in the same folder as the code they are testing and have the _test.go suffix.
To run the tests, simply run go test -tags=exclude_frontend,unit ./... from the root of the backend folder.