搭建Type Script React-Native 遇到測試問題

JS那麼好玩爲何用TS。。node

仍是爲了團隊。react

跟着官網文檔敲基本沒問題,直到單測的時候,yarn run testjson

報錯:react-native

Couldn't find preset "module:metro-react-native-babel-preset" relative to directory  'XXXXX';

解決:進入package.json文件,將jest 配置下的transform替換成如下代碼babel

"transform": {
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js",
"\\.(ts|tsx)$": "ts-jest"
},
相關文章
相關標籤/搜索