docs
Local Development
Alternatives

Alternatives: Honest Opinion

Jest running on Docker can be painfully slow, particularly on macOS. On Linux, the performance is generally much better—luckily, our CI/CD pipeline runs on Ubuntu, so the tests still execute swiftly there. For more context, you might want to check the Jest troubleshooting guide (opens in a new tab).

Performance Tips

To potentially improve test performance in Docker, you could try in package.json:

  • Adding the --runInBand flag to your Jest command.
  • Limiting parallel workers with --maxWorkers=4.

However, your mileage may vary, and these adjustments might not always yield noticeable improvements.

Alternatives to Consider

Here are two options you might explore:

1. Skip Docker Compose for Local Development

Run the backend and postgres locally instead of containerizing it for development and testing. This often results in faster feedback when developing locally.

Step 1: Ensure that PostgreSQL is installed and running locally on your machine.

You can use pgAdmin 4 to manage and inspect your databases visually.

  1. Open pgAdmin 4:
  • Verify that you have a default local PostgreSQL instance running. (This is not the container one)

Create Permission Set

  1. Update Your .env File:
  • Configure your DATABASE_URL in the root .env file to connect to your local PostgreSQL database. Replace <password> with your actual PostgreSQL password.
DATABASE_URL="postgresql://postgres:<password>@localhost:5432/postgres?schema=public"

This configuration assumes that you're using the default postgres database and user. If you're using a custom database name or user, replace postgres accordingly.

Step 2: Start the backend, run the following command from the root directory:
npm run dev

2. Stick with Docker, but Make Adjustments

If you prefer to keep Docker Compose, you might:

  • Switch to Mocha for testing, as it can be less resource-intensive in this setup.
  • Run tests on a Linux system, like Ubuntu, which performs significantly better compared to macOS for Docker workloads.

Final Thoughts

Pick the approach that aligns best with your workflow and environment. Every setup has its pros and cons, so choose what helps you stay productive!