Demo Video
FinalDemoVidoe.mp4
This guide will walk you through the process of setting up the MERN Booking App on your local machine.
Before you begin, ensure you have Node.js installed on your system.
Start by cloning the repository to your local machine:
git clone https://github.com/codewithnadeem14502/Holiday.com.git
cd Holiday.com-
Environment Files: Navigate to the
backendfolder and create two files:.envand.env.e2e. Add the following contents to both files:MONGODB_CONNECTION_STRING= JWT_SECRET_KEY= FRONTEND_URL= # Cloudinary Variables CLOUDINARY_CLOUD_NAME= CLOUDINARY_API_KEY= CLOUDINARY_API_SECRET= # Stripe STRIPE_API_KEY= -
MongoDB Setup:
- Sign up for an account at MongoDB Atlas.
- Create a new cluster and follow the instructions to set up a new database.
- Once set up, obtain your MongoDB connection string and add it to the
MONGODB_CONNECTION_STRINGvariable in your.envfiles. - For the
.env.e2esetup see "running automated tests" below
-
Cloudinary Setup:
- Create an account at Cloudinary.
- Navigate to your dashboard to find your cloud name, API key, and API secret.
- Add these details to the respective
CLOUDINARY_*variables in your.envfiles.
-
Stripe Setup:
- Sign up for a Stripe account at Stripe.
- Find your API keys in the Stripe dashboard.
- Add your Stripe API key to the
STRIPE_API_KEYvariable in your.envfiles.
-
JWT_SECRET_KEY:
- This just needs to be any long, random string. You can google "secret key generator".
-
Frontend URL:
- The
FRONTEND_URLshould point to the URL where your frontend application is running (typicallyhttp://localhost:3000if you're running it locally).
- The
-
Environment Files: Navigate to the
frontendfolder and create a file:.env:VITE_API_BASE_URL= VITE_STRIPE_PUB_KEY= -
VITE_API_BASE_URLL:
- The
VITE_API_BASE_URLshould point to the URL where your backend application is running (typicallyhttp://localhost:7000if you're running it locally).
- The
-
server:
- Navigate to the
serverdirectory. - Install dependencies:
npm install. - Start the server:
npm start.
- Navigate to the
-
client:
- Open a new terminal and navigate to the
clientdirectory. - Install dependencies:
npm install. - Start the frontend application:
npm run dev. - The application should now be running on
http://localhost:5173but verify this in your command line terminal
- Open a new terminal and navigate to the
-
MongoDB Setup:
- You will ideally want to create a new mongoDb database for your tests to run against. This is to keep the data stable
- Sign up for an account at MongoDB Atlas.
- Create a new project (e.g e2e tests)
- Create a new cluster and follow the instructions to set up a new database.
- Once set up, obtain your MongoDB connection string and add it to the
MONGODB_CONNECTION_STRINGvariable in your.env.e2efile.
-
Importing Test Data into MongoDB:
- The repository contains a
datafolder at the root, which includes JSON files for a test user and a test hotel. You can import these into your MongoDB collections to quickly set up test data. - Locate the Test User File: In the
datafolder, find the file containing the test user data (likely named something liketest-users.json). - Open MongoDB Compass: Launch MongoDB Compass and connect to your database.
- Select the Database: In Compass, select the database you are using for the automated tests (created in step 1).
- Import User Data:
- Navigate to the
userscollection within your database. Create it if it doesn't exist - Click on the "Add Data" button and select "Import File".
- Browse to the location of your
test-users.jsonfile and select it. - Choose JSON as the file format and click "Import".
- The test user data will be added to the
userscollection. - user login: 1@1.com/password123
- Navigate to the
- Locate the Test Hotel File:
- Navigate to the
hotelscollection within your database. Create it if it doesn't exist - Repeat the import process as you did for the user data, but this time select the
test-hotel.jsonfile. - Ensure the file format is set to JSON and click "Import".
- The test hotel data will be added to the
hotelscollection.
- Navigate to the
- The repository contains a
-
Running tests
- In VS Code install the Playwright extension
- Navigate to the
e2e-testsdirectory. - Install dependencies:
npm install. - Start the frontend and backend server using the steps above
- Using the Playwright extension to run the tests