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 691
心在旅途
心在旅途 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:49

    had a similar issue when upgrading to 0.57, my package.json still contained an entry for babel-preset-react-native (which is now deprecated in favor of metro-react-native-babel-preset). All I had to do was

    yarn remove babel-preset-react-native

    and then

    yarn add metro-react-native-babel-preset --dev

    Lastly, make sure you change your .babelrc from

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

    to

    {
      "presets": ["module:metro-react-native-babel-preset"]
    }
    

    More info can be found here

提交回复
热议问题