This project was meant to be a place where users can recommend and view music recommendations. The more recommendations a song receives, the better ranked it will be, increasing its possibility of being recommended to other users.
In this way, a test system was created to ensure the functioning of the API provided, as well as the frontend application. Checking in a unitary way the services functions, all route integration and the user experience on the website running.
- Creation of a new recommendation
- Upvote e downvote any recommendation
- Get the latest recommendations
- Get a recommendation
- Get a random recommendation
- Get top recommendations
- Delete a recommendation with score less than -5
The API documentation, implemented with Swagger, can be accessed at the route /documentation
First of all, clone this project and access the folder
git clone https://github.com/GabrielaTiago/Sing-me-a-Song-TESTS.git
cd Sing-me-a-Song-TESTS-
Locally: you need to have Node.js, npm and Postgres installed on your machine.
-
With Docker: you need to have Docker and Docker Compose installed on your machine. With this option, you don't need to install these dependencies on your machine, since the project will run in containers.
The project uses the following environment variables:
PORT: Port where the server will runPOSTGRES_USER: Postgres usernamePOSTGRES_PASSWORD: Postgres user passwordDATABASE_URL: Postgres database connection string
Copy the following content to create the .env and the .env.test files in the root of the backend project
cd BACKEND
cp .env.example .env
cp .env.example .env.test
cd ..Then, replace the values in the files with your own configuration.
# .env
PORT=4000
POSTGRES_USER=[YourUserName]
POSTGRES_PASSWORD=[YourPassword]
DATABASE_URL="postgres://[YourUserName]:[YourPassword]@localhost:5432/singmeasong"; # .env.test
PORT=4000
POSTGRES_USER=[YourUserName]
POSTGRES_PASSWORD=[YourPassword]
DATABASE_URL="postgres://[YourUserName]:[YourPassword]@localhost:5432/singmeasong-test";REACT_APP_BASE_URL: Base URL for the frontendREACT_APP_API_BASE_URL: Base URL for the API
Copy the following content to create the .env file in the root of the frontend project
cd FRONTEND
cp .env.example .env
cd ..Make sure you have Docker and Docker Compose installed on your machine.
You must update the DATABASE_URL in the .env.test located in the BACKEND folder.
DATABASE_URL=postgres://[YourUserName]:[YourPassword]@sing-me-a-song-db-test:5432/singmeasong-testThen, run the following command in the root of the project:
npm run test:e2eThis command will build the Docker images and start the containers for the backend, frontend, and database. The backend will be available at http://localhost:4000 and the frontend at http://localhost:3000.
To run the cypress tests, open a new terminal and run the following command:
cd FRONTEND && npx cypress openThen, follow the steps in the Running the cypress tests section.
To run the backend unit and integration tests, open a new terminal and run the following command:
cd BACKEND npm run docker:testTo stop and remove the containers, run the following command in the root of the project:
npm run docker:downEnter the BACKEND folder
cd BACKENDRun the following command to install the dependencies.
npm installGenerate the database with the following command
npm run dbThen build the project
npm run buildTo start the server, run the command
npm run startTo run the backend unit and integration tests, run the command
npm run testTo run unit tests only, run the command
npm run test:unitTo run integration tests only, run the command
npm run test:integrationNow, open a new terminal and enter the FRONTEND folder
cd FRONTENDRun the following command to install the dependencies.
npm installThen build the project
npm run buildTo start the server, run the command
npm run startStart the cypress
npx cypress openThen, follow the steps in the Running the cypress tests section.
After opening cypress:
- Click on E2E Testing in cypress environment;
- Click on the option Electron
π Attention: For the tests with cypress E2E to work properly, you should keep the server on the backend and frontend running.
Gabriela Tiago de AraΓΊjo
- email: [email protected]
- linkedin: https://www.linkedin.com/in/gabrielatiago/
- portfolio: https://gabrielatiago.vercel.app



