This is a Koa simple application used for testing purposes that exposes few endpoints.
- Fork the public repository https://github.com/GanazHQ/SimpleAPI.git
- Have Node 16.x.x installed locally
- Have a Rest client installed locally, preferably Postman to quickly test the endpoints
- You must know that this project has Jest configured by default, but you are able to use any other testing framework
Once you have the public repository locally, go to the SimpleApi directory.
- Install dependencies:
yarn - Build:
yarn build - Start the application:
yarn start - Two endpoints will be available once the app is started:
GETmethod:http://localhost:9999/api/foo/XwhereXcan be any numberPOSTmethod:http://localhost:9999/api/foowhere the body must be like{ id: X }andXcan be any number
- The application is ready to use
Jestframework for your test cases
- GET
http://localhost:9999/api/foo/X- If
Xis divisible by 2, it returns200code withOKmessage - If
Xis not a number, it returns400code withERROR: Value X is not a numbermessage - Otherwise, it returns
501error code
- If
- POST
http://localhost:9999/api/foo- If body
{ id: 1 }, it returns200code withbarmessage - If body
{ id: 2 }, it returns200code withbassmessage - If body
{ id: anynumber }, it returns200code withunmatchedmessage - If body does not contain property
id, it returns400code withERROR: JSON body must contain id propertymessage
- If body