Scripts
Write pre-request scripts and tests the way you already know how. Kitten accepts Postman, Bruno or Rhai scripts and takes care of the rest, so you don't have to learn a new API or rewrite the scripts you have.
- Bring your Postman scripts.
pm.environment.set(...),pm.test(...),pm.response.json()and the rest work as they are. - Bring your Bruno scripts.
bru.setEnvVar(...),res.getBody(),test(...)andexpect(...)work too. - Or write Rhai. Kitten's own scripting language is short and fast, and it's what every script runs as in the end.
Importing a Postman collection (v2.0 or v2.1 JSON) or a Bruno collection (.bru files or a JSON export) brings its scripts along. Open a request's Script tab to read or edit them.
Scripts run in a sandbox. They start instantly and cannot touch your machine.
The same script, three ways
Each of these sets a token from the response and checks the status. Kitten runs all three the same way.
Postman:
pm.environment.set("token", pm.response.json().token);
pm.test("status is 200", function () {
pm.response.to.have.status(200);
});
Bruno:
bru.setEnvVar("token", res.getBody().token);
test("status is 200", function () {
expect(res.getStatus()).to.equal(200);
});
Rhai:
set_env_var("token", res.body.token);
test("status is 200", || {
chai_equal(res.status, 200, false);
});
What isn't covered yet
Kitten doesn't support every Postman and Bruno command yet. Variables, requests and responses, tests and assertions, runner control, and the common libraries (lodash, CryptoJS, moment, uuid) are covered. A few commands are not, such as pm.visualizer, bru.runRequest and require for modules Kitten doesn't know.
When a script uses one of these, Kitten still imports the request, tells you which line it couldn't handle, and leaves it in the Script tab as // TODO (script): <original> so you can rewrite it. Each command reference below ends with the full list.
Command reference
- Postman to Rhai: every
pm.*andpostman.*command and the Rhai it runs as. - Bruno to Rhai: every
bru.*,req,res,expectandtestcommand and the Rhai it runs as.