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

console.log throws an error for non DOM object that has 'tagName' property #2139

Closed
majuric opened this issue May 17, 2016 · 2 comments · Fixed by #2155 · May be fixed by Omrisnyk/npm-lockfiles#122 or Omrisnyk/npm-lockfiles#132
Closed

Comments

@majuric
Copy link

majuric commented May 17, 2016

Karma overwrites native console.log and tries to stringify every attribute it gets passed into it so it can create an output. In the process if it encounters a DOM node or a DOM Element it attempts to serialize it https://github.com/karma-runner/karma/blob/master/client/stringify.js#L41

The problem is that detection of whether something is a DOM Node is very optimistic. I'm faced with a problem when trying to console.log a Backbone.View ( or any view that inherits form a Backbone.View ) because every Backbone.View has 'tagName' attribute, and this causes the following error in Karma because it expects a DOM node, but gets a Backbone.View in stead.

PhantomJS 2.1.1 (Linux 0.0.0) ERROR TypeError: undefined is not a function (evaluating 'target.dispatchEvent(e)') at http://localhost:9877/karma.js:1363

Possible solution is to change the way of checking if something is a DOM Node / Element http://stackoverflow.com/a/4754156/3193466

Expected behavior

var V = new Backbone.View(); console.log( V )
// Will output the View object in the console

Actual behavior

var V = new Backbone.View(); console.log( V )
`PhantomJS 2.1.1 (Linux 0.0.0) ERROR
TypeError: undefined is not a function (evaluating 'target.dispatchEvent(e)')
at http://localhost:9877/karma.js:1363``

Enviroment Details

  • Karma version (output of karma --version): Karma version: 0.13.22
  • Relevant part of your karma.config.js file: Nothing specific

Steps to reproduce the behaviour

  1. Instantiate a Backbone.View ( Or use any object that has 'tagName' attribute' )
  2. console.log the instance
@iclanzan
Copy link

I have also run into this issue.

@wyuenho
Copy link

wyuenho commented Jun 10, 2016

I ran into this problem too. Would be nice if someone could make a patch release for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment