Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jmfiola/jest-api-test-typescript-example

An example repository which provides the necessary boilerplate for a reusable and maintainable jest test framework
https://github.com/jmfiola/jest-api-test-typescript-example

api-testing api-testing-framework jest rest-api restful-api test-automation test-framework testing-tools typescript typescript-tests

Last synced: about 7 hours ago
JSON representation

An example repository which provides the necessary boilerplate for a reusable and maintainable jest test framework

Awesome Lists containing this project

README

        

[![Build Status][build-shield]][build-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
[![LinkedIn][linkedin-shield]][linkedin-url]





Logo

Jest Api Test Framework: A TypeScript Example


This is an example repository which provides the necessary boilerplate code for a reusable and maintainable jest api test framework using TypeScript.


Report Bug
ยท
Request Feature


Table of Contents



  1. About The Project



  2. Getting Started


  3. Usage

  4. Roadmap

  5. Contributing

  6. License

  7. Contact

## About The Project

This is a basic test framework that hits the [Chuck Norris Jokes API](https://api.chucknorris.io/) following 3 core values:
1. Endpoint functionality should be wrapped by a class method which is abstracted as much as possible ๐ŸŒŒ

2. Those class methods should be unit tested ๐Ÿงช

3. Actual API tests will then import those class methods to interact with the live API ๐Ÿ”Ž

(back to top)

### Built With

* [TypeScript](https://www.typescriptlang.org/)
* [Node.js](https://nodejs.org/en/about/)
* [Jest](https://jestjs.io/docs/getting-started)

(back to top)

## Getting Started
### Prerequisites

You will want the latest version of npm installed. For reference, this project was developed with npm version `8.5.1`.
```sh
npm install npm@latest -g
```

### Installation

1. Clone the repo
```sh
git clone https://github.com/jmfiola/jest-api-test-typescript-example.git
```
3. Install NPM packages
```npm
npm install
```

(back to top)

## Usage

1. Run the unit tests for the framework with code coverage
```npm
npm run unit:test
```
2. Run the functional tests which actually hit the live Chuck Norris API
```npm
npm run functional:test
```

You can use this framework as a starting point for whatever API tests you would like to run. This framework allows for the flexibility of running tests which have free range with what headers they use, what routes they call, etc. whilst also providing easy-to-use, reusable, unit tested class methods. This makes the tests a lot more accessible to test writers and framework maintainers!

(back to top)

## Roadmap

- [ ] Dockerization
- [ ] Reporting Integration
- [ ] Tag-based test collection

See the [open issues](https://github.com/jmfiola/jest-api-test-typescript-example/issues) for a full list of proposed features (and known issues).

(back to top)

## Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. My venmo is [@Jacob-Fiola](https://account.venmo.com/u/Jacob-Fiola)! ๐Ÿ˜‰

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

(back to top)

## License

Distributed under the MIT License. See `LICENSE.txt` for more information.

(back to top)

## Contact

Project Link: [https://github.com/jmfiola/jest-api-test-typescript-example](https://github.com/jmfiola/jest-api-test-typescript-example)

Email: [email protected]

(back to top)

[contributors-shield]: https://img.shields.io/github/contributors/jmfiola/jest-api-test-typescript-example.svg?style=for-the-badge
[contributors-url]: https://github.com/jmfiola/jest-api-test-typescript-example/graphs/contributors
[build-shield]: https://img.shields.io/github/workflow/status/jmfiola/jest-api-test-typescript-example/CI.svg?style=for-the-badge
[build-url]: https://github.com/jmfiola/jest-api-test-typescript-example/actions
[forks-shield]: https://img.shields.io/github/forks/jmfiola/jest-api-test-typescript-example.svg?style=for-the-badge
[forks-url]: https://github.com/jmfiola/jest-api-test-typescript-example/network/members
[stars-shield]: https://img.shields.io/github/stars/jmfiola/jest-api-test-typescript-example.svg?style=for-the-badge
[stars-url]: https://github.com/jmfiola/jest-api-test-typescript-example/stargazers
[issues-shield]: https://img.shields.io/github/issues/jmfiola/jest-api-test-typescript-example.svg?style=for-the-badge
[issues-url]: https://github.com/jmfiola/jest-api-test-typescript-example/issues
[license-shield]: https://img.shields.io/github/license/jmfiola/jest-api-test-typescript-example.svg?style=for-the-badge
[license-url]: https://github.com/jmfiola/jest-api-test-typescript-example/blob/master/LICENSE.txt
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[linkedin-url]: https://linkedin.com/in/jacob-fiola
[product-screenshot]: images/screenshot.png