2016-08-22 16 views
1

私は(http://facebook.github.io/jest/docs/tutorial-react-native.html#contentに応じて)次package.jsonを使用しています:冗談 - Unknow "プリセット" - "冗談反応するネイティブ"

{ 
    "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" 

をしかし、あなたが13.2.3npm -gを使用してインストールされているようです:あなたが持っている

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 

それを行い、あなたが投稿した公式に従ってください、それはあなたが必要とするすべてのものでなければなりません(あなたがテストコードを投稿しなかったので、確かに言えません)。

+0

ご返信ありがとうございます。これは私のキャッシュなどにインストールされているようです... "babel-jest": "*"、 "babel-preset-react-native": "^ 1.9.0"、 "jest -cli ": "*"、 "冗談は、ネイティブ反応:反応テスト・レンダラを " 、 "*""": "*" と "冗談":{ "グローバル":{ "__DEV__":真 }、 "プリセット": "冗談反応するネイティブ"、 "modulePathIgnorePatterns":[ "FBJS"、 "コアJS" ] } に次のスクリプトを追加します。 "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'を試してみることもできました。 –

関連する問題