This solution contains a simple Bank Account MVC project with a REST API back-end and a React front-end built with Vite.
- bank-account.controller.ts: Contains the
BankAccountControllerwhich handles HTTP requests related to bank accounts. - bank-account.model.ts: Defines the
BankAccountclass representing a bank account with properties likeId,AccountNumber,AccountHolderName, andBalance. - bank-account.service.ts: Implements the
BankAccountServiceclass that provides business logic for managing bank accounts.
The Bank Account UI is a React-based front-end application built with Vite that provides a user-friendly interface to interact with the API.
components/Header.tsx: Renders the navigation bar with links.components/Footer.tsx: Displays a fixed footer with copyright information.components/BankAccountTable.tsx: Fetches and displays bank account data in a table format.api/bankAccountApi.ts: Handles API calls to retrieve bank accounts.pages/BankAccountsPage.tsx: Main page that renders theBankAccountTableand integrates layout components.
- bank-account.controller.spec.ts: Contains unit tests for the
BankAccountControllerto ensure correct handling of HTTP requests. - bank-account.service.spec.ts: Contains unit tests for the
BankAccountServiceto verify business logic and data manipulation. - bank-account.model.spec.ts: Contains unit tests for the
BankAccountmodel to verify the correctness of its methods. - bank-account.e2e-spec.ts: Contains end-to-end tests to verify the complete workflow of the application.
- Clone the repository:
git clone <repository-url>
-
Navigate to the project directory:
cd bank-account-api -
Install the dependencies:
npm install
-
Run the API:
npm run start
-
Open the browser and navigate to:
http://localhost:3000/api/BankAccountThis will display the list of bank accounts.
-
Open a new terminal and navigate to the UI project directory:
cd bank-account-ui -
Install the dependencies:
npm install
-
Run the development server:
npm run dev
-
Open the browser and navigate to:
http://localhost:5173
To run the tests in this project, follow these steps:
- Open a terminal and navigate to the API directory.
cd bank-account-api - Run the following command to execute the unit tests:
npm run test - Run the following command to execute the end-to-end tests:
npm run test:e2e
- Run the following command to execute all tests:
npm run test:all
-
Make sure the API is running:
cd bank-account-api npm run start -
In a separate terminal, start the UI application:
cd bank-account-ui npm run dev -
Open a new terminal and run the UI tests:
cd bank-account-ui npm run test:uiThis will run Selenium-based tests that verify the UI components and functionality. The tests require both the API and UI to be running as they test the integration between them.
If you encounter a SessionNotCreatedError when running the UI tests (npm run test:ui) with an error message similar to:
SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version X
Current browser version is Y...
Update the chromedriver npm package to align with your currently installed Chrome browser version:
npm uninstall chromedriver
npm install --save-dev chromedriver@latestThen remove node_modules and package-lock.json and reinstall all dependencies:
rm -rf node_modules package-lock.json
npm installAfter completing these steps, try running the UI tests again: npm run test:ui.
This project may require the following npm packages for testing:
jest: A delightful JavaScript Testing Framework with a focus on simplicity.@nestjs/testing: Utilities for testing NestJS applications.supertest: A library for testing HTTP servers. cd /Users/thalitavergilio/NodeProjects/bank-account-api/bank-account-ui npm run test:uicd /Users/thalitavergilio/NodeProjects/bank-account-api/bank-account-ui npm run test:ui
React: A declarative JavaScript library for building user interfaces.TypeScript: Strongly-typed JavaScript for maintainable code.
To install all dependencies, run:
npm install- Node.js
- NestJS
- TypeScript
- Jest (for testing)
- Supertest (for HTTP assertions)
- React (with Vite)
Feel free to submit issues or pull requests for improvements or bug fixes.
