Skip to content

Ready-to-use template for testing RESTful APIs with Jest, Jest Extended, Supertest & Fake Store API

Notifications You must be signed in to change notification settings

Test-Architect/jest-js-sample

Repository files navigation


Logo

Testing API with Jest + Supertest

A simple and extensible template for API testing using Jest and Supertest.
Ideal for quick setup and custom automation scripting.


About the Project

This repository provides a ready-to-use template for testing RESTful APIs using:

Directory Structure

Directory Structure

Usage

Run all tests

pnpm run test

Generate starter testing files

node scripts/cli <file-name or api-name> --test --api
  • --test: Generate a sample testing file (placed under __test__/)
  • --api: Generate an API helper function file (placed under src/api-helper/)
  • --force | -f: Force overwrite if file exists (please be careful!)

Example:

node scripts/cli product --test --api

Will create:

  • __test__/product.test.js
  • src/api-helper/product.js

Example Test Report:

Sample Report

How to Write Your API Tests

Check out this YouTube Demo Playlist


Getting Started

Prerequisites

Make sure you have Node.js and npm installed:

node -v
pnpm -v

Clone the Repository

git clone https://github.com/Test-Architect/jest-js-sample.git
cd jest-js-sample

Install Dependencies

pnpm install

You're ready to start writing tests!


License

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


Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to improve the template.

About

Ready-to-use template for testing RESTful APIs with Jest, Jest Extended, Supertest & Fake Store API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •