2017-12-18 11 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()メソッドを使用することができます
関連する問題