Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update example to react-native@0.62 #9746

Merged
merged 6 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ exports[`renders the FlatList component 1`] = `
initialNumToRender={10}
keyExtractor={[Function]}
maxToRenderPerBatch={10}
numColumns={1}
onContentSizeChange={[Function]}
onEndReachedThreshold={2}
onLayout={[Function]}
Expand Down
14 changes: 9 additions & 5 deletions examples/react-native/__tests__/intro.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ it('renders the ActivityIndicator component', () => {
});

it('renders the Image component', done => {
Image.getSize('path.jpg', (width, height) => {
const tree = renderer.create(<Image style={{height, width}} />).toJSON();
expect(tree).toMatchSnapshot();
done();
});
Image.getSize(
'path.jpg',
(width, height) => {
const tree = renderer.create(<Image style={{height, width}} />).toJSON();
expect(tree).toMatchSnapshot();
done();
},
done
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this now errors (and times out since we never call done), so I added this. It'll fail, this is the full error:

TypeError: Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.
    at _nonIterableRest (/Users/simen/repos/jest/node_modules/react-native/Libraries/Image/Image.ios.js:24:775)
    at _slicedToArray (/Users/simen/repos/jest/node_modules/react-native/Libraries/Image/Image.ios.js:24:720)
    at /Users/simen/repos/jest/node_modules/react-native/Libraries/Image/Image.ios.js:34:37
    at tryCallOne (/Users/simen/repos/jest/node_modules/react-native/node_modules/promise/lib/core.js:37:12)
    at /Users/simen/repos/jest/node_modules/react-native/node_modules/promise/lib/core.js:123:15
    at flush (/Users/simen/repos/jest/node_modules/asap/raw.js:50:29)
    at processTicksAndRejections (internal/process/task_queues.js:76:11)

Copy link
Collaborator

@thymikee thymikee Apr 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prior to RN 0.62, Image.getSize used NativeModules.ImageViewManager on iOS (and NativeModules.ImageLoader for Android) under the hood, which was mocked in react-native preset: https://github.com/facebook/react-native/blob/caa7829aac01256a1f01dfda73f7d0a5c0371064/jest/setup.js#L214-L223.

With facebook/react-native@d37baa7, it was replaced by NativeImageLoaderIOS which doesn't have a mock.

I can contribute the mock to jest/setup.js, but wanted to know how's Image used at FB that it didn't surface. Maybe it's entirely mocked?

cc @cpojer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are doing some funky stuff internally, that's probably why we didn't notice. I recommend changing the example to something else.

);
});

it('renders the TextInput component', () => {
Expand Down
8 changes: 4 additions & 4 deletions examples/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"test": "jest"
},
"dependencies": {
"react": "16.9.0",
"react-native": "0.61.5"
"react": "16.11.0",
"react-native": "0.62.0"
},
"devDependencies": {
"@babel/core": "*",
"@babel/preset-env": "*",
"babel-jest": "*",
"jest": "*",
"metro-react-native-babel-preset": "*",
"react-test-renderer": "16.9.0"
"metro-react-native-babel-preset": "^0.58.0",
Copy link
Member Author

@SimenB SimenB Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had to manually roll back this in the lock file a few times, and it should be at a specific version anyways, so let's specify it

"react-test-renderer": "16.11.0"
}
}
Loading