我正在尝试对我的react
组件进行测试,但是当我console.log(nav)
错误:
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 :)
代码:
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();
});
});
不太确定如何调试此问题或为何发生这种情况。当我删除console.log(nav)
时,错误没有出现。
答案 0 :(得分:8)
而不是console.log
尝试:
console.log(require('util').inspect(nav, { depth: null }));