Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'replace' of undefined #9

Open
dbkaplun opened this issue Feb 14, 2016 · 6 comments
Open

TypeError: Cannot read property 'replace' of undefined #9

dbkaplun opened this issue Feb 14, 2016 · 6 comments

Comments

@dbkaplun
Copy link

 12:59:54  dan@elise:~/stuff/vernamtools   master ✘ ✹ ✭ 
$ npm test

> vernamtools@1.0.0 test /Users/dan/stuff/vernamtools
> ava -t test/index.js | tap-dot


  .......xx/Users/dan/stuff/vernamtools/node_modules/tap-out/index.js:152
      .replace('(', '')
      ^

TypeError: Cannot read property 'replace' of undefined
    at Parser._handleError (/Users/dan/stuff/vernamtools/node_modules/tap-out/index.js:152:7)
    at Parser.handleLine (/Users/dan/stuff/vernamtools/node_modules/tap-out/index.js:45:8)
    at Stream.<anonymous> (/Users/dan/stuff/vernamtools/node_modules/tap-out/index.js:200:14)
    at emitOne (events.js:77:13)
    at Stream.emit (events.js:169:7)
    at drain (/Users/dan/stuff/vernamtools/node_modules/through/index.js:36:16)
    at Stream.stream.queue.stream.push (/Users/dan/stuff/vernamtools/node_modules/through/index.js:45:5)
    at emit (/Users/dan/stuff/vernamtools/node_modules/split/index.js:37:14)
    at next (/Users/dan/stuff/vernamtools/node_modules/split/index.js:49:7)
    at Stream.<anonymous> (/Users/dan/stuff/vernamtools/node_modules/split/index.js:54:5)
npm ERR! Test failed.  See above for more details.
@scottcorgan
Copy link
Owner

Do you have sample tap output that produces the error?

@almirfilho
Copy link

Same problem on version 1.0.5. Downgraded to 1.0.0 and it's ok there. It only breaks when a test case fail.

@niedzielski
Copy link

niedzielski commented Jun 27, 2018

I can reproduce this issue on v1.0.1, v1.0.5 and v2.0.0:


  .x/home/stephen/Code/wmf/vagrant/mediawiki/extensions/Popups/node_modules/trim/index.js:5
  return str.replace(/^\s*|\s*$/g, '');
             ^

TypeError: Cannot read property 'replace' of undefined
    at trim (/home/stephen/Code/wmf/vagrant/mediawiki/extensions/Popups/node_modules/trim/index.js:5:14)
    at Parser._handleError (/home/stephen/Code/wmf/vagrant/mediawiki/extensions/Popups/node_modules/tap-out/index.js:184:14)
    at Parser.handleLine (/home/stephen/Code/wmf/vagrant/mediawiki/extensions/Popups/node_modules/tap-out/index.js:46:8)
    at Stream.<anonymous> (/home/stephen/Code/wmf/vagrant/mediawiki/extensions/Popups/node_modules/tap-out/index.js:212:14)
    at Stream.emit (events.js:182:13)
    at drain (/home/stephen/Code/wmf/vagrant/mediawiki/extensions/Popups/node_modules/through/index.js:36:16)
    at Stream.stream.queue.stream.push (/home/stephen/Code/wmf/vagrant/mediawiki/extensions/Popups/node_modules/through/index.js:45:5)
    at emit (/home/stephen/Code/wmf/vagrant/mediawiki/extensions/Popups/node_modules/split/index.js:37:14)
    at next (/home/stephen/Code/wmf/vagrant/mediawiki/extensions/Popups/node_modules/split/index.js:49:7)
    at Stream.<anonymous> (/home/stephen/Code/wmf/vagrant/mediawiki/extensions/Popups/node_modules/split/index.js:54:5)

The input is:

TAP version 13
ok 1 ext.popups/actions > #boot
not ok 2 ext.popups/actions#linkDwell @integration > #linkDwell
  ---
  message: "The dispatcher was called with the correct arguments."
  severity: failed
  actual: {
  "type": "LINK_DWELL",
  "el": {
    "0": {},
    "length": 1,
    "prevObject": {
      "0": {},
      "length": 1
    }
  },
  "event": {},
  "token": "9876543210",
  "title": "Foo",
  "namespaceId": 1,
  "promise": 0,
  "timestamp": "2018-06-27T13:36:07.775Z"
}
  expected: {
  "type": "LINK_DWELL",
  "el": {
    "0": {},
    "length": 1,
    "prevObject": {
      "0": {},
      "length": 1
    }
  },
  "event": {},
  "token": "9876543210",
  "timestamp": "2018-06-27T13:36:07.775Z",
  "title": "Foo",
  "namespaceId": 1
}
  stack:     at Object.<anonymous> (/home/stephen/Code/wmf/vagrant/mediawiki/extensions/Popups/tests/node-qunit/actions.test.js:124:9)
  ...
ok 3 ext.popups/actions#linkDwell @integration > #linkDwell doesn't continue when previews are disabled
ok 4 ext.popups/actions#linkDwell @integration > #linkDwell doesn't continue if the token has changed
ok 5 ext.popups/actions#linkDwell @integration > #linkDwell dispatches the fetch action
ok 6 ext.popups/actions#fetch > it should fetch data from the gateway immediately
ok 7 ext.popups/actions#fetch > it should dispatch the FETCH_END action when the API request ends
ok 8 ext.popups/actions#fetch > it should delay dispatching the FETCH_COMPLETE action
ok 9 ext.popups/actions#fetch > it should dispatch the FETCH_FAILED action when the request fails
ok 10 ext.popups/actions#fetch > it should dispatch the FETCH_FAILED action when the request fails even after the wait timeout
ok 11 ext.popups/actions#abandon > it should dispatch start and end actions
ok 12 ext.popups/actions#abandon > it shouldn't dispatch under certain conditions
ok 13 ext.popups/actions#saveSettings > it should dispatch an action with previous and current enabled state
ok 14 ext.popups/actions#previewShow > it should dispatch the PREVIEW_SHOW action and log a pageview
ok 15 ext.popups/actions#previewShow > PREVIEW_SEEN action not called if activeToken changes
ok 16 ext.popups/actions#previewShow > PREVIEW_SEEN action not called if preview type not page
ok 17 ext.popups/changeListener > it should only call the callback when the state has changed
ok 18 ext.popups/eventLogging > it should log the queued event
ok 19 ext.popups/eventLogging > it should call the eventLogged bound action creator
ok 20 ext.popups/changeListeners/footerLink @integration > it should append the link to the footer menu

v1.0.0 works as expected:

  .x..................  


  ---
  message: "The dispatcher was called with the correct arguments."
  severity: failed
  actual: {
  "type": "LINK_DWELL",
  "el": {
    "0": {},
    "length": 1,
    "prevObject": {
      "0": {},
      "length": 1
    }
  },
  "event": {},
  "token": "9876543210",
  "title": "Foo",
  "namespaceId": 1,
  "promise": 0,
  "timestamp": "2018-06-27T13:36:07.775Z"
}
  expected: {
  "type": "LINK_DWELL",
  "el": {
    "0": {},
    "length": 1,
    "prevObject": {
      "0": {},
      "length": 1
    }
  },
  "event": {},
  "token": "9876543210",
  "timestamp": "2018-06-27T13:36:07.775Z",
  "title": "Foo",
  "namespaceId": 1
}
  stack:     at Object.<anonymous> (/home/stephen/Code/wmf/vagrant/mediawiki/extensions/Popups/tests/node-qunit/actions.test.js:124:9)
  ...
  

  20 tests
  19 passed
  1 failed  

  Failed Tests:   There was 1 failure

    x ext.popups/actions#linkDwell @integration > #linkDwell

wmfgerrit pushed a commit to wikimedia/mediawiki-extensions-Popups that referenced this issue Jun 27, 2018
The tap-dot executable crashes on some test failure outputs.[0] This is
confusing since a test failure in itself often requires debugging. The
issue is present from v1.0.1 to the latest, v2.0.0.

Instead of downgrading, replace tap-dot with the popular
tap-mocha-reporter. This change comes with a bonus: console.log is no
longer filtered out. The benefit cannot be overstated.

[0]: scottcorgan/tap-dot#9

Change-Id: I4ce2d2816885b7c5214f5c1863be595be0d8b1aa
@Qix-
Copy link

Qix- commented Aug 3, 2018

Yep facing this too - here's much simpler TAP input to test with:

TAP version 13
not ok 1 failure
  ---
  message: Test case aborted
  severity: fail
  ...
not ok 2 segfault
  ---
  message: Test case segfaulted
  severity: fail
  ...
ok 3 skipped # SKIP Symbol prefixed with underscore (_TEST_skipped)
ok 4 hello
1..4

and the error:

xx  ..


  ---
  message: Test case aborted
  severity: fail
/usr/local/lib/node_modules/tap-dot/bin/dot:65
        out.push(chalk.white(stackPadding + failure.error.stack.replace(/\n/g, '\n  ' + stackPadding)) + '\n');
                                                                ^

TypeError: Cannot read property 'replace' of undefined
    at /usr/local/lib/node_modules/tap-dot/bin/dot:65:65
    at Array.forEach (<anonymous>)
    at PassThrough.<anonymous> (/usr/local/lib/node_modules/tap-dot/bin/dot:58:14)
    at PassThrough.emit (events.js:180:13)
    at Stream.<anonymous> (/usr/local/lib/node_modules/tap-dot/node_modules/tap-out/index.js:215:14)
    at Stream.emit (events.js:185:15)
    at Stream.stream.destroy (/usr/local/lib/node_modules/tap-dot/node_modules/through/index.js:84:12)
    at _end (/usr/local/lib/node_modules/tap-dot/node_modules/through/index.js:67:14)
    at Stream.stream.end (/usr/local/lib/node_modules/tap-dot/node_modules/through/index.js:74:5)
    at PassThrough.onend (/usr/local/lib/node_modules/tap-dot/node_modules/readable-stream/lib/_stream_readable.js:577:10)

@bitmage
Copy link

bitmage commented Oct 2, 2018

I get this when I pass an error that has endlines in the message body. Same issue with tap-spec: scottcorgan/tap-spec#64

@3cp
Copy link

3cp commented Dec 5, 2019

It was a tap-out issue. scottcorgan/tap-out#33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants