This project is an example of API tests using TypeScript, Jest and SuperTest.
We are using FakeRestAPI.Web as a system.
- TypeScript
- Jest
- SuperTest
- Commit lint and Commitizen
- ESlint
- Prettier
- Husky
- Github Actions
- Jest HTML Reporter on Github Pages
- node >= 12.x - how to install Node
- npm >= 6.14.x - how to install NPM
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.
We also have watch mode for Jest and TypeScript:
npm run build:watch
npm run test:watch
Run to format the code:
npm run code:format
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.