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
This is a basic test framework that hits the Chuck Norris Jokes API following 3 core values:
-
Endpoint functionality should be wrapped by a class method which is abstracted as much as possible 🌌
-
Those class methods should be unit tested 🧪
-
Actual API tests will then import those class methods to interact with the live API 🔎
You will want the latest version of npm installed. For reference, this project was developed with npm version 8.5.1
.
npm install npm@latest -g
- Clone the repo
git clone https://github.com/jmfiola/jest-api-test-typescript-example.git
- Install NPM packages
npm install
- Run the unit tests for the framework with code coverage
npm run unit:test
- Run the functional tests which actually hit the live Chuck Norris API
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!
- Dockerization
- Reporting Integration
- Tag-based test collection
See the open issues for a full list of proposed features (and known issues).
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! 😉
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!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Project Link: https://github.com/jmfiola/jest-api-test-typescript-example
Email: jmfiola21@gmail.com