ApiTestAutomation

This framework is to test web services using javascript

Stars
2

API Test Framework

Table of Contents

Prerequisites

Installation

Install Node.js and pnpm

Ensure you have Node.js and pnpm installed. You can download them from the following links:

Install Node Modules

To install the required node modules, run:

pnpm install

Run Tests

  • npm test to run all test

Generate HTML Reports using jest-html-reporters

To generate HTML reports for your tests, you can use jest-html-reporters. The configuration is already set up in jest.config.ts.

Making HTTP Requests using axios

This project uses axios for making HTTP requests. You can find the helper functions for making GET, POST, PATCH, and DELETE requests in src/helper/apiHelper.ts.

Generating Fake Data using faker

This project uses faker for generating fake data. You can find an example of how to use faker in src/helper/create.ts.

Additional Jest Matchers using jest-extended

This project uses jest-extended for additional Jest matchers. The configuration is already set up in jest.config.ts.

Usage

const { HttpGet, HttpPost, HttpPatch, HttpDelete } = require('../helper/apiHelper');
const { baseUrl, getEndpoint } = require('../config/config');

Example Get Start

const { HttpGet, HttpPost, HttpPatch, HttpDelete } = require('../helper/apiHelper');
const { baseUrl, getEndpoint } = require('../config/config');

describe('API Testing Framework', () => {
  test('should get all posts', async () => {
    const endpoint = getEndpoint('getPosts');
    const response = await HttpGet(`${baseUrl}${endpoint?.path}`);

    expect(response.status).toEqual(200);
    expect(response.data).toBeInstanceOf(Array);
  });
});

Built With

Dependency Use
Axios Promise based HTTP client for the browser and node.js
Faker generate massive amounts of fake data
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,
rimraf The UNIX command rm -rf for node
cross-env Run scripts that use environment variables across platforms

Results

Badges
Extracted from project README
ApiTest CI