React Native with Typescript and Jest is broken after 0.57 Update: Couldn't find preset “module:metro-react-native-babel-preset” relative to directory

后端 未结 3 809
心在旅途
心在旅途 2021-02-02 14:01

If you integrate test with Jest and Enzyme in the new React Version 0.57 and TypeScript, they won\'t work. Here are the steps to reproduce:

Create a new React Native pro

3条回答
  •  自闭症患者
    2021-02-02 14:41

    I found the answer here in this issue: https://github.com/facebook/metro/issues/242#issuecomment-421139247

    Basically, add this to your Jest section in package.json:

    "transform": { "^.+\\.js$": "/node_modules/react-native/jest/preprocessor.js" }
    

提交回复
热议问题