@kingojs/kingo
v0.9.4
Published
Write better test cases
Downloads
5
Readme
金吾 (Kingo)
Kingo is a REST API testing framework with the following goals:
- Generate Postman collections
- Be an easy-to-learn tool
- Be a friendly tool for Developers and QA Engineers
- Have organized code
- Be able to write test cases from any text-editor/IDE
- Get rid of Postman UI
Why?
Postman is a powerful tool with a lot of useful features that allow developers to perform quality tests with ease but writing test cases from Postman UI can be a little bit annoying, especially because Postman UI was not meant to work as a text-editor.
By using Kingo, developers will be able to have a better versioning control of their test cases.
Also, Kingo allows developers to use different languages like: JavaScript (Vanilla [recommended]), TypeScript, CoffeeScript, Clojure, PureScript, and a long et cetera.
Use example
This is the folder structure to be followed in order to generate the Postman collection.
.
└── collection/
├── api_01/
│ ├── test_case_01/
│ │ ├── prerequest.js
│ │ ├── request.json
│ │ ├── body.json
│ │ └── tests.js
│ ├── test_case_02/
│ │ ├── prerequest.js
│ │ ├── request.json
│ │ ├── body.json
│ │ └── tests.js
│ ├── readme.md
│ └── prerequest.js
├── api_02/
│ ├── test_case_01/
│ │ ├── prerequest.js
│ │ ├── request.json
│ │ ├── body.json
│ │ └── tests.js
│ ├── test_case_02/
│ │ ├── prerequest.js
│ │ ├── request.json
│ │ ├── body.json
│ │ └── tests.js
│ └── readme.md
├── variables.json
├── readme.md
└── prerequest.js
Import kingonize
from @kingojs/kingo
and send an object as the one bellow and provide the required fields.
import { kingonize } from '@kingojs/kingo';
kingonize({
root: './collection', // files location
// The APIs you want to include
APIS: [
'API_01',
'API_02'
],
// prefix for each file type
prefixes: {
request: 'request', // method and url
prerequestScript: 'prerequest', // script running before request
variables: 'variables', // global variables (collection level)
body: 'body', // in JSON format
tests: 'tests', // script running after request
documentation: 'readme' // markdown file
}
});
Finally, execute the script as a normal NodeJS file.
node main.js
Note I: It is important to notice that it is not necessary to create all the different type of files, notices how API_02
does not contain a prerequest.js
file, whilst API_01
does.
Note II: Make sure the request.json
file has the following structure:
{
"method": "get",
"request_url": "{{base_url}}/test"
}
Compile
If you want to compile the project, you can use the following command:
npx tsc
tsconfig.json file will do the magic for you!
Reporting
newman-reporter-htmlextra is a perfect compliment for Kingo, by using this module you can run collections generated by Kingo directly from the terminal to get fully rid of Postman UI.
TODO
- Authentication support
- Non-REST APIs support
- Implicit APIs selection
Why is it named 金吾?
Because of the one and only 濱田金吾 (Kingo Hamada)!