Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError on target.dispatchEvent when console.log variable

I am trying to run tests on my react components but I am getting this error when I console.log(nav)

error:

Chrome 44.0.2403 (Mac OS X 10.10.4) App has nav FAILED
    Error: the error "TypeError: target.dispatchEvent is not a function" was thrown, throw an Error :)

code:

import React from 'react/addons';
var TestUtils = React.addons.TestUtils;
import testHelper from '../../test/helpers/testHelper.js';
import App from '../../app/views/app.js';
var app = testHelper.getRouterComponent(App);

describe('App', function() {
    it('has nav', function(done) {
        var nav = TestUtils.findRenderedDOMComponentWithTag(app, 'nav');
        console.log(nav);
        expect(nav).to.exist;
        done();
    });
});

Not quite sure how to debug this or why this is occurring. When I removed the console.log(nav) the error does not appear.

like image 350
Liondancer Avatar asked Aug 13 '15 17:08

Liondancer


1 Answers

Instead of console.log try :

console.log(require('util').inspect(nav, { depth: null }));
like image 69
Sébastien Avatar answered Sep 28 '22 19:09

Sébastien