This repository demonstrates API automation based on a series of API calls in the DMoney API collection. It performs a set of actions including logging in as an admin, creating users (customers and an agent), transferring funds between users, and verifying account balances.
The automated test script performs the following steps:
- Login
- Log in as an admin using credentials:
- Create Users
- Create 2 new customers
- Create 1 new agent
- Transfer Funds
- Transfer 2000 tk from the System account to the newly created agent
- Deposit: 1500 tk is deposited to a customer from the agent account
- Withdraw: 500 tk is withdrawn by the customer to the agent
- Send Money: 500 tk is sent from one customer to another
- Payment: 100 tk is paid to a merchant by the recipient customer
- Check Balance
- Verify the balance of the recipient customer
├── test
│ └── dmoney.test.js // Contains the API tests
├── testRunner
│ ├── reportGenerator.js // Generates the Mochawesome report
│ └── testrunner.js // Script to run the tests
├── utils
│ └── myUtils.js // Utility functions used across tests
├── user-list.json // JSON file to store created users' info
├── .env // Environment variables (baseUrl, partnerKey, token)
├── package.json
└── .gitignore // Should include node_modules & package-lock.json
-
Clone the Repository
git clone https://github.com/nafizkamal11/APIAutomation-using-Mocha-and-Axios-on-DMoney.git cd APIAutomation-using-Mocha-and-Axios-on-DMoney
-
Install Dependencies
Make sure you have Node.js installed, then run:
npm install
To run the automated tests, use the following command:
npm test file test/dmoney.test.js
This command executes the test runner located at testRunner/testrunner.js
, which in turn runs the API tests in test/dmoney.test.js
.
After running the tests, generate the Mochawesome report with:
npm start file test/dmoney.test.js
This script (testRunner/reportGenerator.js
) creates a detailed report of your test runs.
Below is a screenshot of the generated Mochawesome report: