Liondancer
Liondancer

Reputation: 16469

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.

Upvotes: 6

Views: 1546

Answers (1)

Sébastien
Sébastien

Reputation: 341

Instead of console.log try :

console.log(require('util').inspect(nav, { depth: null }));

Upvotes: 8

Related Questions