tap-spec icon indicating copy to clipboard operation
tap-spec copied to clipboard

Cannot read property 'replace' of undefined

Open bitmage opened this issue 6 years ago • 1 comments

.../node_modules/trim/index.js:5
  return str.replace(/^\s*|\s*$/g, '');
             ^

TypeError: Cannot read property 'replace' of undefined
    at trim (.../node_modules/trim/index.js:5:14)
    at Parser._handleError (.../node_modules/tap-out/index.js:187:14)
    at Parser.handleLine (.../node_modules/tap-out/index.js:48:8)
    at Stream.<anonymous> (.../node_modules/tap-out/index.js:241:14)
    at Stream.emit (events.js:180:13)
    at drain (.../node_modules/through/index.js:36:16)
    at Stream.stream.queue.stream.push (.../node_modules/through/index.js:45:5)
    at emit (.../node_modules/split/index.js:37:14)
    at next (.../node_modules/split/index.js:49:7)
    at Stream.<anonymous> (.../node_modules/split/index.js:54:5)

I get this when using:

const tape = require('tape')
const {test} = tape
tape.createStream()
  .pipe(require('tap-spec')())
  .pipe(process.stdout);

And calling t.err(error) on an error that contains endlines in the message body.

bitmage avatar Oct 02 '18 18:10 bitmage

I had this problem also. I noticed that tape-spec depends on tape-out, I ran it on tap-out and found it crached with that error message. It turns out that tape-out sometimes breaks on lines that don't begin with ok, not, or #. So it put in and extra filter to put a # on lines that begin with a space

(some-test-rig) | sed 's/^ /#/1' | npm tap-out

and then it passed the particular output I was throwing at it. But I think there are more issues besides just this one.

.../node_modules/trim/index.js:5
  return str.replace(/^\s*|\s*$/g, '');
             ^

TypeError: Cannot read property 'replace' of undefined
    at trim (.../node_modules/trim/index.js:5:14)
    at Parser._handleError (.../node_modules/tap-out/index.js:187:14)
    at Parser.handleLine (.../node_modules/tap-out/index.js:48:8)
    at Stream.<anonymous> (.../node_modules/tap-out/index.js:241:14)
    at Stream.emit (events.js:180:13)
    at drain (.../node_modules/through/index.js:36:16)
    at Stream.stream.queue.stream.push (.../node_modules/through/index.js:45:5)
    at emit (.../node_modules/split/index.js:37:14)
    at next (.../node_modules/split/index.js:49:7)
    at Stream.<anonymous> (.../node_modules/split/index.js:54:5)

I get this when using:

const tape = require('tape')
const {test} = tape
tape.createStream()
  .pipe(require('tap-spec')())
  .pipe(process.stdout);

And calling t.err(error) on an error that contains endlines in the message body.

craigphicks avatar Jan 04 '21 00:01 craigphicks