Skip to content

dipjyotimetia/ApiTestAutomation

Repository files navigation

ApiTest CI

Api Test Framework

Install node

Nodejs > 14.0

Install node modules

npm i

Run Tests

  • npm test to run all test
  • npm run local to run specific test

Run Tests in docker

  • ./build-docker.sh to run all tests in docker container

Usage

const expect = require('chai').expect,                   // Import chai for assertions
    faker = require('faker'),                           // Faker library to generate fake data
    supertest = require('supertest'),                  // Api test library
    logger = require('../config/logger')(__filename), // Logging info/errors

Example Get Start

const expect = require('chai').expect,
    faker = require('faker'),
    supertest = require('supertest'),
    account = require('../api/Account'),
    config = require('../config/config'),
    logger = require('../config/logger')(__filename),
    api = supertest(`${config.BASE_URL}`);

describe(`Test Description`,()=>{

    let clientAuth;
    let authToken;

    beforeEach(`GetAuthToken`, async ()=>{
         
    });

    it(`Test Name`, async ()=>{
        try {
          const res = await api.get('END_POINT')
                .set('Accept', 'application/x-www-form-urlencoded')
                .expect(200);
           expect(res.body).to.have.property('PROPERTY_NAME');     
        } catch (error) {
            logger.error(`Error reason`${error});
            throw Error(error);
        }
    });
})

Built With

Dependency Use
SuperTest HTTP assertions made easy via superagent to test GET/POST/Delete
Sinon Standalone test spies, stubs and mocks for JavaScript
Axios Promise based HTTP client for the browser and node.js
Mocha Mocha is a feature-rich JavaScript test framework
Lokijs In-memory JavaScript Datastore with Persistence
Mochawesome Mochawesome is a custom reporter for use with the JS mocha
Winston simple and universal logging library
Knex SQL query builder for Postgres, MSSQL, MySQL
DotEnv Dotenv is a zero-dependency module that loads environment
Chai assertion library for node
Faker generate massive amounts of fake data
Prettyjson Package for formatting JSON data in a coloured YAML-style
uuid Simple, fast generation of RFC4122 UUIDS.
npm-run-all A CLI tool to run multiple npm-scripts in parallel or sequential.
lodash odash makes JavaScript easier working with arrays,
chai-http HTTP integration testing with Chai assertions.
rimraf The UNIX command rm -rf for node
cross-env Run scripts that use environment variables across platforms

Results

About

This framework is to test web services using javascript

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published