I am reading the reactjs
documentation but I am having a having a hard time fully understanding it. I wish there were more step by step examples.
I want to be able to test my components and their child components but I am not sure how to create mocks or instances of my components to test them.
code:
import React from 'react/addons';
import Layout from '../../app/views/layout.js';
var TestUtils = React.addons.TestUtils;
var mockLayout;
describe('Layout (deep copy)', function() {
beforeEach(function() {
mockLayout = TestUtils.renderIntoDocument(<Layout />);
});
it('is DOM Component', function(done) {
assert(TestUtils.isDOMComponent(mockLayout));
done();
});
});
I am getting the error and I am not sure what it means:
TypeError: Cannot read property 'getRouteAtDepth' of undefined
at RouteHandler.createChildRouteHandler (base/spec/views/layout.js:23821:39)
at RouteHandler.render (base/spec/views/layout.js:23836:27)
at ReactCompositeComponentMixin._renderValidatedComponentWithoutOwnerOrContext (base/spec/views/layout.js:12011:35)
at ReactCompositeComponentMixin._renderValidatedComponent (base/spec/views/layout.js:12038:15)
at ReactPerf.measure.wrapper (base/spec/views/layout.js:3744:22)
at ReactCompositeComponentMixin.mountComponent (base/spec/views/layout.js:11459:31)
at ReactPerf.measure.wrapper [as mountComponent] (base/spec/views/layout.js:3744:22)
at Object.ReactReconciler.mountComponent (base/spec/views/layout.js:3819:36)
at ReactDOMComponent.ReactMultiChild.Mixin.mountChildren (base/spec/views/layout.js:13014:45)
at ReactDOMComponent.Mixin._createContentMarkup (base/spec/views/layout.js:12598:33)window.__karma__.result @ debug.html:37(anonymous function) @ adapter.js:98require.register.EventEmitter.emit @ mocha.js:616(anonymous function) @ adapter.js:73require.register.EventEmitter.emit @ mocha.js:611require.register.Runner.fail @ mocha.js:4797require.register.Runner.failHook @ mocha.js:4822(anonymous function) @ mocha.js:4863done @ mocha.js:4518require.register.Runnable.run @ mocha.js:4558next @ mocha.js:4855(anonymous function) @ mocha.js:4876timeslice @ mocha.js:6483