Modding postman to get detailed test reports

Amal Jossy,postman

Disclaimer: Modifying the source has technical and legal consequences which I shall not be held accountable for. This post is for purely educational purposes. I recommend using newman (opens in a new tab) to get better reports

Around June 2020 I was working on creating a "test suite" for some REST resources. I was limited to using Postman (opens in a new tab) and no other tools were allowed. It went great. I set up a postman collection that uses an external data file to perform tests iteratively

Sadly if you wish to generate reports, at least in JSON format, you would lose a lot of the contextual info like request and response bodies and other useful information. Now, newman lets you generate a detailed report in many formats including Html- which was also a requirement. I looked into what all features postman was offering in detail and learned that the only way to get what I want is by modifying the app itself.

Postman is built on top of the electron framework which makes it possible to edit the javascript the app uses. All you need would be the asar package and knowledge of postman's inner working. the latter is easy to find out by using the DevTools-similar to the one in chromium- found under View->Developer->Show Devtools. Use it to trace the function we need to modify. In my case, it was TransformToBackbone function in js/vendor-shared.js

Now that we understand what we need to change, its time to use asar (opens in a new tab). Find the app.asar file in %LOCALAPPDATA%/Postman/app-<version>/resources folder. We need to extract the contents of this asar 'archive' and repack it after making changes. Do:

  1. Run npx asar e %LOCALAPPDATA%\Postman\app-7.30.0\resources\app.asar app
  2. open app/js/vendor-shared.js
    1. Find TransformToBackbone function and make necessary changes in my case, I changed it to
      const TransformToBackbone = (runId, run, cb) => {
      // const exportRun = {
      // id: runId,
      // name:,
      // timestamp: new Date(run.createdAt).toISOString(),
      // collection_id:,
      // folder_id: ? : 0,
      // environment_id: run.environment || '0',
      // totalPass: run.totalTestCount - run.failedTestCount,
      // totalFail: run.failedTestCount,
      // results: getResults(run.iterations),
      // count: run.iterations.length,
      // totalTime: getTotalTime(run.iterations),
      // collection: {
      //     requests:[0], item => ({ id:, method: _.get(item, 'request.method') })) } };
      const detailedExport= _.pick(run,['collection','createdAt','delay','failedTestCount','id','iterations','name','requestSelection','totalTestCount']);
      cb(null, detailedExport);

      Note that we can use any library postman already uses, which includes lodash. Thanks

    2. Save the file
  3. Run npx asar p app app.asar to create the new app.asar with the changes you made
  4. Replace the file in %LOCALAPPDATA%/Postman/app-&lt;version&gt;/resources folder with the new archive you repacked
  5. Restart postman and see the change