Skip to content
John Lecegues edited this page Mar 15, 2024 · 5 revisions

Guides

This section aims to give useful guides & information to the developer.

Setup Guides

Guides relating to setting up the project, environment, etc.

Setting up & Using ESLint/Prettier

VSCode

  1. Download the ESLint Extension
  2. Download the Prettier Extension
  3. Set to auto-format on save by pressing CTRL + SHIFT + P and going to Open User Settings (JSON) and adding these:
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
  "source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode"
  1. Run npm install in both frontend and backend directories to make sure ESLint and Prettier packages are installed

Using ESLint & Prettier

  • There are separate configurations in both frontend/ and backend/, so these steps should be done on both ends.
  1. npm run format will check code formatting using Prettier in the directory
  2. npm run format:fix will fix all code formatting errors using Prettier in the directory
  3. npm run lint will show all linting errors in the directory
  4. npm run lint:fix will fix all linting errors in the directory

Setting up & Using Playwright

Setting up Playwright

  1. cd into the /testing directory
  2. Run npm install then npx playwright install; this will install the Playwright browsers and dependencies

Using Playwright: Scripts

  1. First, cd into the folder you want to run tests from (e.g. smoke-test)

To run the tests normally:

npx playwright test 

To run the tests with an interactive UI Window

npx playwright test --ui

To run the debugger and step through the testing phases

npx playwright test --debug

Docker Guides

Guides relating to Docker, Docker containers, etc.

Useful Docker Commands

To build the container

docker-compose build {--no-cache (does not reuse cache)} {service-name (builds specific service)}

To start all containers

docker-compose up {--build (builds before starting)} {-d (detach from container console)}

To stop all containers

docker-compose down

To list all running containers and their details

docker-compose ps

To attach a running container's bash terminal to interact with it via bash terminal

docker-compose exec {service-name} bash

Special script to find the ip of the containers' postgres serivce

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' term-project-2024-team-4-postgres-1

Accessing PGAdmin 4 From the Container

Additionally, PGAdmin4 can be accessed at http://localhost:5050. Instructions to access database via PGAdmin4:

  1. Head to http://localhost:5050
  2. Enter credentials specified in docker-compose.yaml
  1. Press "Connect Server" and enter a name for it (can be anything)
  2. Head to "Connection" tab and find the "Host name/address" through the terminal using this script:
    docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' term-project-2024-team-4-postgres-1
    
  3. Enter database, username, and password specified in your .env file. Default is db: postgres, username: postgres, and password: your_password
  4. Connect and should be able to access "my_database" with pre-generated schemas