Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an effective way to review code written in Postman?

Tags:

postman

As all Postman collections are basically .json files it's quite difficult to review code written in Postman via code review tools.

At the moment I continue to review such .json files on GitHub, however, it's not quite convenient.

For instance, here's some JS code sent for review in .json format

        "listen": "test",
        "script": {
            "id": "e8f64f04-8ca5-4b5a-8333-1f6bde73cf0c",
            "exec": [
                "var body = xml2Json(responseBody);",
                "// const resp = pm.response.json();",
                "let resp = body.projects;",
                "var b = \"New_Poject_e2e\"+pm.environment.get(\"random_number\");",
                " console.log(b);",
                "for (var i = 0; i < resp.project.length; i++)",
                "{",
                "    if (resp.project[i].name === b)",
                "    {",
                "    console.log(resp.project[i].id[\"_\"]);",
                "    pm.environment.set(\"projID\", resp.project[i].id[\"_\"]);",
                "    }",
                "}",
                ""
            ],
            "type": "text/javascript"
        }

Is there an effective way to carry out code review for Pre-request scripts, Requests, and Tests for Postman Collections?

like image 378
5 revsuser1106925 Avatar asked Oct 28 '25 19:10

5 revsuser1106925


1 Answers

Have you tried creating a fork of the Collection?

https://learning.getpostman.com/docs/postman/collections/version_control/#forking-a-collection

You can make changes in the Forked Collection and then Merge them - Before merging you get taken to the web view which might make these diffs easier.

Postman diff

like image 140
Danny Dainton Avatar answered Oct 31 '25 13:10

Danny Dainton