2017-10-19 10 views
-1

enzime 및 jest에 대한 업그레이드와 함께 React 16으로 업그레이드하기 전에 많은 테스트가 제대로 수행되었습니다. 나는 the instructions을 따라 내 package.json효소 및 농산물에 대한 수입이 16 번 테스트에서 실패했습니다

"jest": { 
    "globals": { 
    "rootLevel": "/portal" 
    }, 
    "moduleNameMapper": { 
    "components": "<rootDir>/../components", 
    "\\.(jpg|jpeg|png|gif|svg|woff|woff2)$": "<rootDir>/_tests/__mocks/fileMock.js" 
    }, 
    "setupFiles": [ 
    "<rootDir>/_tests/__config/shim.js", 
    "<rootDir>/_tests/__config/enzyme-setup.js" 
    ] 
} 

의 농담의 CONFIGS에이 두 파일을 추가하지만 난 여전히 내 테스트가 제대로 실행 보이지 않아요. 내 테스트의 대부분이 동일 오류가 발생합니다 :

Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. 

Check the render method of `WrapperComponent`. 
at invariant (node_modules/fbjs/lib/invariant.js:42:15) 
... 
at mount (node_modules/enzyme/build/mount.js:19:10) 
at Object.<anonymous> (_tests/MyTest.test.js:39:35) 

가이 줄이었다 트리거 그 모든 : 지금까지 내가 말할 수있는대로

const wrapper = mount(<MyComponent {...props} />) 

, mount 여전히 효소 3. 모든에서 동일하게 작동 뭔가 렌더링과 관련된 내 테스트가 실패했습니다. 내가 뭘 놓치고 있니?

"components$": "<rootDir>/../components", 

답변

0

문제

$ 모듈 이름 매퍼에서 누락 된 것이 었습니다. 그렇지 않으면 create-react-app를 사용하여이 파일을 자동 생성해야합니다.
+0

난 당신이 게시 된 URL의에서 "구성 요소"모든 참조를 참조하지 않습니다 – HoldOffHunger