This project was generated with Angular CLI version 15.2.5.
Run:
ng servefor a dev server. Navigate to http://localhost:4200/. The application will automatically reload if you change any of the source files.
Run:
ng generate component component-nameto generate a new component. You can also use:
ng generate directive|pipe|service|class|guard|interface|enum|moduleRun:
ng buildto build the project. The build artifacts will be stored in the dist/ directory.
This project includes both frontend and backend tests.
Run unit tests using Karma:
ng testRun end-to-end tests:
ng e2eTo use end-to-end testing, you need a platform-specific testing package installed.
The backend uses Jest and Supertest to test API endpoints.
- Node.js >= 18
- MongoDB running locally or via a connection string in
.env - Dependencies installed:
npm installCreate a .env file at the project root with the following variables:
MONGO_URI=mongodb://127.0.0.1:27017/smartstock
SESSION_SECRET=your_session_secret
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GOOGLE_CALLBACK_URL=http://localhost:3000/auth/google/callbackFor running tests, you may use a separate test database to avoid modifying production data.
Run all tests:
npm testRun a specific singleProduct.test.js file:
npm test -- tests/singleProduct.test.jsRun a specific listProduct.test.js file:
npm test -- tests/listProduct.test.jsRun tests sequentially (useful for database operations):
npm test -- --runInBand-
singleProduct.test.js– Single product tests:- Return a single product by ID
- Return 404 if product is not found
- Return 400 for invalid product ID
-
listProduct.test.js– Multiple product tests:- Return an empty array when no products exist
- Return all products when they exist
- Handle server errors gracefully
⚠️ Ensure MongoDB is running locally or thatMONGO_URIpoints to a valid database before running backend tests.
To get more help on the Angular CLI use:
ng helpor check out the Angular CLI Overview and Command Reference page.