2016-08-22 5 views
1

을 내가 (http://facebook.github.io/jest/docs/tutorial-react-native.html#content에 따라) 다음 package.json을 사용하고 있습니다 :농담 - 알 수없는 "사전"- "농담 --반응 기본"

{ 
    "scripts": { 
    "start": "node node_modules/react-native/local-cli/cli.js start", 
    "test": "jest", 
    }, 
    "dependencies": { 
    "react": "^15.3.1", 
    "react-native": "0.31.0", 
    }, 
    "devDependencies": { 
    "babel-jest": "^14.1.0", 
    "babel-preset-react-native": "^1.9.0", 
    "jest": "^14.1.0", 
    "jest-cli": "^13.1.0", 
    "jest-react-native": "^14.1.3", 
    "react-test-renderer": "^15.3.1" 
    }, 
    "jest": { 
    "globals": { 
     "__DEV__": true, 
     "__RCTProfileIsProfiling": false 
    }, 
    "preset": "jest-react-native" 
    } 
} 

하지만 오류 얻을 :

Error: Unknown config option "preset" with value "jest-react-native". This is either a typing error or another user mistake and fixing it will remove this message. 
Using Jest CLI v13.2.3, jasmine2, babel-jest 
FAIL __tests__/AuthorRequest-test.js (0s) 
● Runtime Error 
    - Error: Cannot find module 'throwOnWrongReactAPI' from 'react-native.js' 
     at Resolver.resolveModule (node_modules/jest-cli/node_modules/jest-resolve/build/index.js:197:17) 
     at eval (node_modules/react-native/Libraries/react-native/react-native.js:180:26) 
     at Object.<anonymous> (node_modules/react-native/Libraries/react-native/react-native.js:189:4) 
1 test suite failed, 0 tests passed (0 total in 1 test suite, run time 2.238s) 
npm ERR! Test failed. See above for more details. 

내 .babelrc 파일이 포함되어 있습니다 : 당신이 농담의 잘못된 버전을 사용하는 느낌이

{ 
    "presets": ["react-native"] 
} 

답변

0

.

"jest": "^14.1.0", 
"jest-cli": "^13.1.0" 

를하지만 당신이 npm -g를 사용 13.2.3를 설치 한 것 : 당신은 모두의

Using Jest CLI v13.2.3, jasmine2, babel-jest 

첫째, 난 당신이 jest-cli를 제거하고 단지 jest 14.1.0를 사용할 수 있다고 생각합니다.

이런 식으로
"scripts": { 
    "test": "./node_modules/jest/bin/jest.js" 
} 

, 당신은 당신이 당신의 프로젝트의 로컬 농담 복사본을 실행해야합니다, 그래서 지금 말해야한다 : 같은

그런 다음 당신은 당신의 test 스크립트를 업데이트 할 수 있습니다

Using Jest CLI v14.1.0, jasmine2, babel-jest 

그 일을하고 공무원 docs을 게시 한 후에는 필요한 모든 것이되어야합니다 (테스트 코드를 게시하지 않았으므로 확실히 말할 수 없습니다).

+0

답장을 보내 주셔서 감사합니다. jast가 캐시에 설치되어있는 것처럼 보였습니다. 업데이트 : "babel-jest": "*", "babel-preset-react-native": "^ 1.9.0", "jest -cli ":"* ", "농담이-네이티브 반응 : 반응 테스트 - 렌더러 " ,"* "" ""* " 및 "농담 ": { "전역 ": { "__DEV__"참 } "사전": "농담 - 반응 - 네이티브" "modulePathIgnorePatterns을"[ "fbjs" "코어 JS" ] } ,617,다음 스크립트를 사용하십시오. "clean-all": "rm -rf node_modules /; rm -f tsconfig.json; npm 캐시 정리; npm install; " – Arvind

+0

그건 그렇고, https://facebook.github.io/jest/docs/troubleshooting.html#caching-issues. 그래서'jest --no-cache'를 시도해 볼 수도 있습니다. –

관련 문제