patman
patman

Reputation: 2840

react-native 56.0 update: snapshot tests different

after i upgraded my react-native version in a simple project to react-native 56.0 my snapshots look different. I have not found any hint that this is supposed to be different in the new version (maybe it is though).

I had to work through another issue (supposedly with babel 7) and add the react-native transformer to my jest configuration:

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

I did not have to it before. Anyway my snapshots look different that instead of <Text>-Nodes it renders just <Component>-Nodes. Which makes the diff look like this a lot:

-   </Text>
-   <Text
-     accessible={true}
-     allowFontScaling={true}
-     ellipsizeMode="tail"
+   </Component>

Anybody has a hint why this is happening or if this is supposed to be happening? Should i update my snapshots or is this a problem that i need to tackle?

Thank you!

Upvotes: 0

Views: 244

Answers (1)

A. Goodale
A. Goodale

Reputation: 1348

Did you upgrade jest and babel-jest to version 23.x also? This version of jest changes the snapshot results by excluding props that have no value set, but it shouldn't change the type of component in the JSX. Make sure your jest dependencies are the same as those specified in React Native 0.56's package.

Also, to fix the jest preprocessor problem, try adding a babel.config.js in addition to your babelrc. That allowed us to continue to use babel-jest in the transform.

Upvotes: 2

Related Questions