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"]
}
답장을 보내 주셔서 감사합니다. 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
그건 그렇고, https://facebook.github.io/jest/docs/troubleshooting.html#caching-issues. 그래서'jest --no-cache'를 시도해 볼 수도 있습니다. –