Newman: Issue with custom reporters in Docker

Created on 16 Mar 2020  ยท  5Comments  ยท  Source: postmanlabs/newman

  1. Newman Version (can be found via newman -v):
    4.6.0

    1. OS details (type, version, and architecture):
      Linux (within a docker container, if that changes anything)

    2. Are you using Newman as a library, or via the CLI?
      CLI

    3. Did you encounter this recently, or has this bug always been there:
      Recently

    4. Expected behaviour:
      Running correctly

    5. Command / script used to run Newman:
      newman run
      /usr//collections/SmokeTests.postman_collection.json
      -e /usr//collections/environment.json
      -r

    6. Sample collection, and auxiliary files (minus the sensitive details):
      The issue is not in the collection/environment files

    7. Screenshots (if applicable):
      N/A


I have created a custom reporter. This reporter works fine when I run it locally on my machine having installed both newman and the reporter globally.

~ โฏ ls /usr/lib/node_modules/
newman  newman-reporter-<custom_reporter_name>  npm

However, when inside a docker container, it apparently fails. As you can see from the following logs, both newman and the reporter are installed globally as well, and appear in the same directory.

Step 14/20 : RUN npm install -g newman
/usr/bin/newman -> /usr/lib/node_modules/newman/bin/newman.js
+ [email protected]
added 166 packages from 197 contributors in 12.175s

Step 15/20 : 
RUN npm install -g /usr/<project_folder>/newman-reporter-<custom_reporter_name>
+ newman-reporter-<custom_reporter_name>@0.0.1
added 167 packages from 198 contributors in 7.742s

(...)

Step 17/20 : RUN ls /usr/lib/node_modules
newman
newman-reporter-<custom_reporter_name>
npm

Step 18/20 : RUN ls /usr/lib/node_modules/newman-reporter-<custom_reporter_name>
index.js
node_modules
package.json

When I launch the container, which contains a Python script executing the newman command posted above in CLI mode, I receive the following error:

container    | newman: could not find "<custom_reporter_name>" reporter
container    |   ensure that the reporter is installed in the same directory as newman
container    |   please install reporter using npm
container    | 

Thanks in advance for your help

Most helpful comment

@shamasis I might have found the issue, but I'm struggling to reproduce it consistently.

In some cases, if the code of the custom reporter has some type of JS error, instead of failing explicitly and raising the JS error, newman says it can't find the reporter.

Hope this helps somehow.

All 5 comments

Apparently upgrading the Node version to 13 solved the issue. Any idea of the reason for this?

Nope. Very odd. Closing for now. Will look forward to know more as to why this happened. Meanwhile I will explore as well.

@shamasis I might have found the issue, but I'm struggling to reproduce it consistently.

In some cases, if the code of the custom reporter has some type of JS error, instead of failing explicitly and raising the JS error, newman says it can't find the reporter.

Hope this helps somehow.

Oh yeah. This helps.

I think this was fixed and we forgot to update the issue. @mohitranka can you get this checked?

Was this page helpful?
0 / 5 - 0 ratings