GithubHelp home page GithubHelp logo

api-comparator's Introduction

api-comparator

This repository contains automated tests for comparing the endpoints API using Mocha and Chai.

Pre-Requisites

Node.js v14.0.0 or newer

Table of Contents

  1. Getting Started
  2. Folder Structure
  3. Setup
  4. Running Tests
  5. Adding New Tests

Getting Started

To get started with the project, clone the repository to your local machine.

git clone [email protected]:fathirwafda/api-comparator.git
cd api-comparator

Folder Structure

The project has the following folder structure:

project-root
│
|
├── src
|   ├── fileComparator.js          # Collections of logic/control for our tests/scenarios
|
├── tests                          # Test directory
│   ├── apiComparator.test.js      # Tests for simple comparator
│   └── apiFileComparator.test.js  # Tests for comparator by using files
│   
├── node_modules                   # Node.js modules
├── package.json                   # Node.js package manifest file
└── README.md                      # This file
└── reports                        # Generated report when the test is done
    └── mochawesome
        └── assets
        └── mochawesome.html       # Report file in html format
        └── mochawesome.json       # Report file in json

Setup

  1. Install Node.js: If not already installed, download and install Node.js from Node.js Official Website.

  2. Edit the package.json as the following configuaration Or make your own if you are familiar with it

    {
      "name": "apitest-automation-mocha",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "test": "mocha 'test/**/*.test.js' --recursive --reporter mochawesome --reporter-options reportDir=reports/mochawesome/ --timeout 180000",
        "reports": "open 'reports/mochawesome/mochawesome.html'"
      },
      "keywords": [],
      "author": "Fathir Wafda",
      "license": "MIT",
      "devDependencies": {
        "chai": "^4.3.8",
        "chai-http": "^4.4.0",
        "mocha": "^10.2.0",
        "dotenv": "^7.0.0",
        "mochawesome": "^3.0.2"
      }
    }
    
  3. Install Dependencies: Navigate to the project root directory in the terminal and run the following command to install the necessary dependencies:

npm install

Running Tests

Navigate to the project root directory in the terminal and run the following command to execute the tests:

npm run test

Sample Report alt text

Adding New Tests

  1. Create Test File: Create a new .test.js file under the relevant directory inside the test/api folder.
  2. Write Test: Use Mocha and Chai to write your test cases in the newly created .test.js file.
  3. Run Test: Use the npm test command to run your tests and validate that they are working as expected.

api-comparator's People

Contributors

fathirwafda avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.