Skip to content

A Node.js project to automate API activities on the Dmoney platform using Mocha for testing, Axios for HTTP requests, and Mochawesome for reporting.

Notifications You must be signed in to change notification settings

nafizkamal11/APIAutomation-using-Mocha-and-Axios-on-DMoney

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Automation using Mocha and Axios on DMoney

Overview

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.

Implemented Work

The automated test script performs the following steps:

  1. Login
    • Log in as an admin using credentials:
  2. Create Users
    • Create 2 new customers
    • Create 1 new agent
  3. 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
  4. Check Balance
    • Verify the balance of the recipient customer

Project Structure

├── 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

Setup and Installation

  1. 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
    
  2. Install Dependencies

    Make sure you have Node.js installed, then run:

    npm install
    

Running the Tests

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.

Generating the Report

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.

Screenshot

Below is a screenshot of the generated Mochawesome report:

image

Dependencies

  • Mocha – Testing framework
  • Chai – Assertion library
  • Axios – Promise-based HTTP client
  • Mochawesome – Reporting tool
  • dotenv – Environment variable loader
  • faker – For generating random test data
  • shelljs – For executing shell commands

About

A Node.js project to automate API activities on the Dmoney platform using Mocha for testing, Axios for HTTP requests, and Mochawesome for reporting.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published