newman -v):when newman in jenkins and if fail test, newman gets error in cell.js

but sucessful in CLI

@dmnlk This appears to be a noTTY conflict issue, could you try adding export TERM=xterm before the newman command runs in your Jenkins environment?
@kunagpal
i tried this , but get same error
sudo docker run -e TERM=xterm --volume=/jenkins/workspace/:/var/newman -t newman run /var/newman/collection/fail.postman_collection.json --environment=/var/newman/environment/dev.postman_environment.json
@kunagpal
ok, thanks.
but i got same error still now

@dmnlk Not sure if this is applicable to you, but I got the exact same error and fixed it by testing against http instead of https.
@czardoz This could be due to a missing .toString() call here: https://github.com/postmanlabs/newman/blob/develop/lib/reporters/cli/index.js#L60, as compared to https://github.com/postmanlabs/newman/blob/develop/lib/reporters/cli/index.js#L65
Any update on this bug? Running into the same problem
@grioja, any chance you could share the collection causing this problem?
I think this is strictly related to printing out the results of the collection run (when it succeeds or fails). I'm using --no-color --bail
Running into the same problem as well. I am seeing the problem when running the newman-docker image within a Jenkins build pipeline.
I'm seeing this same issue as well using the newman-docker image running from jenkins. Everything works good except the failure-details summary
I was also experiencing this issue. My hypothesis is that this occurs because newman explicitly calls cli-table2 with colWidths = undefined. You can see this exact behavior for example with a free-style jenkins pipeline project with this definition:
sh """
npm install cli-table2
echo "var Table = require('cli-table2');" > script.js
echo "var table = new Table({ head: ['TH 1 label', 'TH 2 label'], colWidths: undefined });" >> script.js
echo "table.push(['First value', 'Second value']);" >> script.js
echo "console.log(table.toString());" >> script.js
node script.js
"""
This will provide output like this:
+ node script.js
/var/jenkins_home/workspace/test3/node_modules/cli-table2/src/cell.js:52
var fixedWidth = tableOptions.colWidths[this.x];
^
TypeError: Cannot read property '0' of undefined
at Cell.mergeTableOptions (/var/jenkins_home/workspace/test3/node_modules/cli-table2/src/cell.js:52:42)
I think the error is inside the parseFailures function in index.js when setting colWidths. Here's the relevant snippet:
colWidths: cliUtils.noTTY() ? [] : (function (size, indexOrder) {
var colWidths;
if (size.exists && size.width && (size.width > 20)) {
colWidths = [];
colWidths[0] = indexOrder + 3;
colWidths[1] = parseInt((size.width - colWidths[0]) * 0.2, 10);
colWidths[2] = parseInt(size.width - (colWidths[0] + colWidths[1] + 5), 10);
}
return colWidths;
}(cliUtils.dimension(), Number(failures.length.toString().length)))
In cases where the if statement is false the colWidths will end up with the invalid value of undefined.
The fix at first sight seems to be simply to initialize the var directly with [].
Forgot to mention, you can also repro this issue by running newman run coll.json locally on this coll.json file:
{
"item": [{
"name": "Test",
"request": { "url": "http://bogus.url.here" }
}]
}
If you do it in a really small window (under 20 characters wide). Which makes sense given the if statement mentioned in previous comment.
I'm running into this issue running the newman docker container in a Jenkins pipeline, I've found that adding the --reporter-cli-no-failures flag to my command gets me past the failure until this is fixed.
What worked for me was not using -t in the docker run command. My exact syntax was:
docker run -v $temp_folder/postman:/etc/newman \
postman/newman_alpine33 \
--collection="my_collection.json" \
--environment="my_environment.json" \
--testReportFile="/path/to/results.xml"
@kunagpal
I'm seeing this same issue as well and i am not using docker image provided by newman, instead we have created a new docker image and executing command in that container. Everything works good except the failure-details summary.
can u help me how can i fixed this issues?
Just hit this as well. I'm running newman on CircleCI (ie a Docker environment) and don't have a lot of control about how it's being run.
@kunagpal what was the solution to close this issue?
With GitHub Actions, the same issue has been occurred. (Each action block seems to build docker image with -t option)
How to solve this problem?
// local execution using `act`
...
[test api] docker build -t npm:master /var/folders/l6/hmb_c4h54t576pkg2dr6df740000gn/T/act/actions/npm@master
...
so is there no way to run this with tty and not get this error?
any news here?
What's interesting is that I can run it with -t when the postman files are local files mounted but when I run the collection through the API it fails.
Hello @kunagpal, still running into this issue. I'm on [email protected] and also I can't control the -t flag in the docker command. From the CLI it works ok.
/usr/local/lib/node_modules/newman/node_modules/cli-table3/src/cell.js:60
let fixedWidth = tableOptions.colWidths[this.x];
^
TypeError: Cannot read property '0' of undefined
at Cell.mergeTableOptions (/usr/local/lib/node_modules/[4mnewman[24m/node_modules/[4mcli-table3[24m/src/cell.js:60:44)
at Table.<anonymous> (/usr/local/lib/node_modules/[4mnewman[24m/node_modules/[4mcli-table3[24m/src/table.js:27:14)
at Array.forEach (<anonymous>)
at Table.<anonymous> (/usr/local/lib/node_modules/[4mnewman[24m/node_modules/[4mcli-table3[24m/src/table.js:26:11)
at Array.forEach (<anonymous>)
at Table.toString (/usr/local/lib/node_modules/[4mnewman[24m/node_modules/[4mcli-table3[24m/src/table.js:25:11)
at EventEmitter.<anonymous> (/usr/local/lib/node_modules/[4mnewman[24m/lib/reporters/cli/index.js:90:22)
at EventEmitter.emit (/usr/local/lib/node_modules/[4mnewman[24m/node_modules/[4meventemitter3[24m/index.js:203:33)
at /usr/local/lib/node_modules/[4mnewman[24m/lib/run/index.js:328:33
at wrapper (/usr/local/lib/node_modules/[4mnewman[24m/node_modules/[4masync[24m/internal/once.js:12:16)
at iteratorCallback (/usr/local/lib/node_modules/[4mnewman[24m/node_modules/[4masync[24m/eachOf.js:56:13)
at /usr/local/lib/node_modules/[4mnewman[24m/node_modules/[4masync[24m/internal/onlyOnce.js:12:16
at wrapper (/usr/local/lib/node_modules/[4mnewman[24m/node_modules/[4masync[24m/dist/async.js:268:20)
at next (/usr/local/lib/node_modules/[4mnewman[24m/node_modules/[4masync[24m/dist/async.js:4582:24)
at /usr/local/lib/node_modules/[4mnewman[24m/node_modules/[4masync[24m/dist/async.js:321:20
at /usr/local/lib/node_modules/[4mnewman[24m/lib/run/export-file.js:41:13
Given @jeroenheijmans comment, I just sent a PR that apparently solves it: https://github.com/postmanlabs/newman/pull/2576
Most helpful comment
What worked for me was not using
-tin thedocker runcommand. My exact syntax was: