Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dipjyotimetia/apitestautomation
This framework is to test web services using javascript
https://github.com/dipjyotimetia/apitestautomation
api docker mock nodejs
Last synced: 2 months ago
JSON representation
This framework is to test web services using javascript
- Host: GitHub
- URL: https://github.com/dipjyotimetia/apitestautomation
- Owner: dipjyotimetia
- Created: 2019-03-01T02:47:29.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-16T22:18:04.000Z (3 months ago)
- Last Synced: 2024-09-17T11:56:51.111Z (3 months ago)
- Topics: api, docker, mock, nodejs
- Language: TypeScript
- Homepage: https://dipjyotimetia.github.io/ApiTestAutomation/
- Size: 2.58 MB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
[![ApiTest CI](https://github.com/dipjyotimetia/ApiTestAutomation/actions/workflows/apitest.yml/badge.svg)](https://github.com/dipjyotimetia/ApiTestAutomation/actions/workflows/apitest.yml)
# API Test Framework
## Table of Contents
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Install Node.js and pnpm](#install-nodejs-and-pnpm)
- [Install Node Modules](#install-node-modules)
- [Install TypeScript](#install-typescript)
- [Running Tests](#running-tests)
- [Generating HTML Reports](#generating-html-reports)
- [Making HTTP Requests](#making-http-requests)
- [Generating Fake Data](#generating-fake-data)
- [Additional Jest Matchers](#additional-jest-matchers)
- [Usage](#usage)
- [Example](#example)## Prerequisites
- [Node.js >= 20.0](https://nodejs.org/en/)
- [pnpm >= 9](https://pnpm.io/)## Installation
### Install Node.js and pnpm
Ensure you have Node.js and pnpm installed. You can download them from the following links:
- [Node.js](https://nodejs.org/en/)
- [pnpm](https://pnpm.io/)### Install Node Modules
To install the required node modules, run:
```sh
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
```javascript
const { HttpGet, HttpPost, HttpPatch, HttpDelete } = require('../helper/apiHelper');
const { baseUrl, getEndpoint } = require('../config/config');
```
## Example Get Start
```javascript
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](https://github.com/axios/axios/blob/master/README.md) | Promise based HTTP client for the browser and node.js |
| [Faker](https://www.npmjs.com/package/faker) | generate massive amounts of fake data |
| [uuid](https://github.com/kelektiv/node-uuid#readme) | Simple, fast generation of RFC4122 UUIDS. |
| [npm-run-all](https://github.com/mysticatea/npm-run-all) | A CLI tool to run multiple npm-scripts in parallel or sequential.|
| [lodash](https://lodash.com/) | odash makes JavaScript easier working with arrays, |
| [rimraf](https://github.com/isaacs/rimraf#readme) | The UNIX command rm -rf for node |
| [cross-env](https://github.com/kentcdodds/cross-env#readme) | Run scripts that use environment variables across platforms |### Results