렌더링한 컴포넌트 클래스 메서드를 사용하고 싶을 경우
const Wrapper = shallow(<MyComponent />);
Wrapper.instance().myMethod() 와 같이 쓰면 되는데
typescript를 사용하고 있다면 린트에서 에러를 발생시킨다.
const instance = Wrapper.instance() as MyComponent;
instance.myMethod();
와 같이 캐스팅해서 쓰면 된다.
'TDD&BDD' 카테고리의 다른 글
mocha] Resolution method is overspecified. Specify a callback *or* return a Promise; not both. (0) | 2019.11.22 |
---|---|
es6의 class method 방식과 enzyme 호환 문제 (0) | 2018.07.17 |
react mocha asynchronous function test(비동기 함수 테스트) (0) | 2018.07.16 |