Skip to content

WarleyGabriel/api-tests-jest-supertest-example

Repository files navigation

API tests with Jest and SuperTest

jest Commitizen friendly Action Status License

This project is an example of API tests using TypeScript, Jest and SuperTest.
We are using FakeRestAPI.Web as a system.

Features

Requirements

Getting Started

Install the dependencies:

npm install

Compile TypeScript:

npm run build

Run api tests:

npm run test
 PASS  dist/specs/Books.test.js (7.384 s)
  Managing books
    ✓ /GET - All books (1096 ms)
    ✓ /GET - An specific book (1101 ms)
    ✓ /POST - A new book (1217 ms)
    ✓ /PUT - Update a book (1229 ms)
    ✓ /DELETE - Remove a book (1228 ms)
    ✓ /CONTRACT - Check contract of getting books (1076 ms)

Test Suites: 1 passed, 1 total
Tests:       6 passed, 6 total
Snapshots:   0 total
Time:        8.16 s, estimated 13 s
Ran all test suites matching /.\/dist\/specs\/Books.test.js/i.

Watch mode

We also have watch mode for Jest and TypeScript:

npm run build:watch
npm run test:watch

Prettier and Eslint

Run to format the code:

npm run code:format

Commit

We use the best practices for message's commit, using Commit lint and Commitizen we can generate changelogs automatically.

Run npm run commit and commitizen will help you.

Releases

No releases published

Packages

No packages published