@jbscript/rest-runner
v1.0.10
Published
A simple REST API runner using Axios
Downloads
30
Readme
Getting Started
A simple REST API runner using Axios
Installation
Below is an example of how you can install and setup this package.
import RestRunner from "@jbscript/rest-runner";
const executor = new RestRunner();
const response = await executor.send(payload);
Payload Sample
{
"url": "https://postman-echo.com/post",
"method": "POST",
"body": {
"type": "application/json",
"data": "{\n \"id\":123,\n \"name\":\"jabir\"\n}",
"form": [
{
"id": "6DZo29cPhzx6gHlobQRK6",
"key": "",
"value": "",
"enable": true
}
]
},
"authorization": {
"type": "none",
"token": "",
"username": "",
"password": ""
},
"parameters": [
{
"id": "3lZxqD5dgJJnL-SEDLziy",
"key": "",
"value": "",
"enable": true
}
],
"headers": [
{
"id": "FLMQdu6-tG_Uht495mpcv",
"key": "",
"value": "",
"enable": true
}
],
"testscript": "aq.test(\"Status code is 200\", () => {\n return aq.expect(aq.response.status).toBe(200);\n}); \n\naq.test(\"Status code is 4xx\", () => {\n return aq.expect(Math.floor(aq.response.status / 100) === 4).toBe(true);\n}); \n\n",
"timeout": 50000,
"maxRedirects": 5,
"withCredentials": false
}
Roadmap
- [x] Form Data (since form is a browser specific object / we can use form-data [npm] in node )
- [x] Form Upload File
- [x] Isolating Test Script (if browser run using webworker / in node VM2 or other alternative (Not sure maybe worker_threads or childprocess is also an option))
- [x] Pre Script run
- [x] tv4 for schema validation
- [x] chai for assertion
Tips
- (browser-or-node) [can be used to identify where the code is running]
- (tsup) [compile to commonjs and esm]