2017-12-18 36 views

답변

2

enzyme을 사용하는 경우 옵션을 전달하여 얕은 렌더링 또는 전체 DOM 렌더링을 할 때 컨텍스트를 설정할 수 있습니다. (docs here) :

예를 들면 : 당신이 노드의 컨텍스트를 테스트하려면

import { shallow, mount } from 'enzyme'; 

// ...... 

const testContext = { getPath:() => 'foo' }; 
const shallowWrapper = shallow(<SomeComponent />, { context: testContext }); 

// or 

const fullWrapper = mount(<SomeComponent />, { context: testContext }); 

당신은 enzyme

에서 .context() 방법을 사용할 수 있습니다