Answer the question
In order to leave comments, you need to log in
Can't test React component method, why?
Hello.
Unable to test methods in class react component. Here is the method:
testSum(a, b) {
return a + b;
const wrapper = shallow(<МойКомпонент/>);
console.log(wrapper.instance().testSum(2,4).toBe(6));
Connect {
props: {},
context: {},
refs: {},
updater:
Updater {
_renderer:
ReactShallowRenderer {
_context: {},
_element: [Object],
_instance: [Circular],
_newState: null,
_rendered: [Object],
_rendering: false,
_forcedUpdate: false,
_updater: [Circular],
_dispatcher: [Object],
_workInProgressHook: null,
_firstWorkInProgressHook: null,
_isReRender: false,
_didScheduleRenderPhaseUpdate: false,
_renderPhaseUpdates: null,
_numberOfReRenders: 0 },
_callbacks: [] },
selectDerivedProps: [Function: selectDerivedProps],
selectChildElement: [Function: selectChildElement],
indirectRenderWrappedComponent: [Function: bound indirectRenderWrappedComponent],
state: null,
setState: [Function] }
Answer the question
In order to leave comments, you need to log in
Connect {
props: {},
context: {},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question