https://github.com/sadabnepal/pactum-api-test
api testing using pactum with mock services
https://github.com/sadabnepal/pactum-api-test
api-testing-framework eslint pactumjs rest-api
Last synced: 2 months ago
JSON representation
api testing using pactum with mock services
- Host: GitHub
- URL: https://github.com/sadabnepal/pactum-api-test
- Owner: sadabnepal
- Created: 2024-03-07T12:32:22.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-07T04:27:36.000Z (over 1 year ago)
- Last Synced: 2025-03-14T17:26:14.691Z (10 months ago)
- Topics: api-testing-framework, eslint, pactumjs, rest-api
- Language: TypeScript
- Homepage:
- Size: 46.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# api testing using pactum js with mock data
### getting started
```
git clone https://github.com/sadabnepal/pactum-api-test.git
cd pactum-api-test
```
### pre-requisite
[](https://nodejs.org/en/download/)
[](https://code.visualstudio.com/download)
### set environment
```
export ENV=local
OR
export ENV=dev
```
### run test
```
npm run test
```
### stub details
The project is using [pactum mock](https://pactumjs.github.io/guides/mock-server.html) which provides following endpoints
`GET: /api/users/{id}` fetches the user information by `user id`
`POST: /api/users` fetches the user with query parameter `{ page: 2 }`
`POST: /api/users` creates user with body `{ name: 'Ken', job: 'Test Engineer' }`
`GET: /bearer` authenticate user with token that includes `Bearer`
### learning references:
pactum: https://pactumjs.github.io/introduction/welcome.html
supertest: http://visionmedia.github
mocha: https://ricostacruz.com/mocha/
mocha config: https://github.com/mochajs/mocha/tree/master/example/config
eslint: https://eslint.org/docs/latest/use/getting-started
vscode settings: https://code.visualstudio.com/docs/getstarted/settings
Blog: https://medium.com/@joaovitorcoelho10/pactumjs-a-next-gen-rest-api-testing-tool-ae88a9e51916
### TODO:
- better reusable http calls