Skip to content
This repository has been archived by the owner on Jan 17, 2021. It is now read-only.

Stacktrace Data can be an array #39

Merged
merged 5 commits into from
Jan 3, 2021

Conversation

nwestfall
Copy link

I've noticed that in one of my test files, the stacktrace data was actually being parsed as an array, instead of a string causing this error

Payload

{
  _attributes: {
    name: 'Response time is less than 1000ms',
    time: '6.287',
    classname: 'REDACTED'
  },
  failure: {
    _attributes: {
      type: 'AssertionFailure',
      message: 'expected 6287 to be below 1000'
    },
    _cdata: [
      'Failed 1 times.',
      'Collection JSON ID: REDACTED.',
      'Collection name: REDACTED.',
      'Request name: REDACTED.',
      'Test description: Response time is less than 1000ms.',
      'Error message: expected 6287 to be below 1000.',
      'Stacktrace: AssertionError: expected 6287 to be below 1000\n' +
        '   at Object.eval sandbox-script.js:2:1).'
    ]
  }
}
Going to parse results form tests/postman-node/newman/*.xml
Error: ((testcase.failure && testcase.failure._cdata) || (testcase.failure && testcase.failure._text) || (testcase.error && testcase.error._cdata) || (testcase.error && testcase.error._text) || "").trim is not a function

To fix this, simply calling toString before trim, will join the data if it's an Array.

@mikepenz
Copy link
Owner

mikepenz commented Jan 2, 2021

Thank you so much for the pr.

@mikepenz mikepenz merged commit 25388f4 into mikepenz:main Jan 3, 2021
@mikepenz mikepenz added the fix label Jan 3, 2021
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants