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

closes #13034 Fixes the ScrollViewMock methods #13048

Closed
wants to merge 8 commits into from

Conversation

alvaromb
Copy link
Contributor

Motivation (required)

Solves #13034

Now the ScrollView mock has all the methods available.

Test Plan (required)

React Native tests pass.

To test this specific part of the code,

$ react-native init Test
$ cd Test/
$ yarn add react-navigation

Then, add a simple project that uses react-navigation:

import React from 'react';
import { Text } from 'react-native';
import { StackNavigator } from 'react-navigation';

class HomeScreen extends React.Component {
  static navigationOptions = {
    title: 'Welcome',
  };
  render() {
    return <Text>Hello, Navigation!</Text>;
  }
}

const SimpleApp = StackNavigator({
  Home: { screen: HomeScreen },
});

export default SimpleApp

Run the default render tests:

$ npm run test

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. GH Review: review-needed labels Mar 21, 2017
@@ -17,7 +17,9 @@ const requireNativeComponent = require('requireNativeComponent');

const RCTScrollView = requireNativeComponent('RCTScrollView');

class ScrollViewMock extends React.Component {
const ScrollViewComponent = jest.genMockFromModule('ScrollView');

Choose a reason for hiding this comment

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

identifier jest Could not resolve name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would need some guidance to avoid this eslint error @satya164.

Copy link
Contributor

Choose a reason for hiding this comment

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

Add /* eslint-env jest */ to the top

Added lint rule to avoid unresolved identifier error
@@ -17,7 +18,9 @@ const requireNativeComponent = require('requireNativeComponent');

const RCTScrollView = requireNativeComponent('RCTScrollView');

class ScrollViewMock extends React.Component {

Choose a reason for hiding this comment

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

identifier jest Could not resolve name

@satya164
Copy link
Contributor

@facebook-github-bot shipit

@facebook-github-bot
Copy link
Contributor

@satya164 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@alvaromb
Copy link
Contributor Author

alvaromb commented Apr 5, 2017

Hey @satya164!

Can I help you with something else with this PR?

@shergin
Copy link
Contributor

shergin commented May 29, 2017

@alvaromb Seems this PR breaks tests. Could you please take a look?

@alvaromb
Copy link
Contributor Author

alvaromb commented Jun 6, 2017

Hi @shergin!

Sorry, I forgot about this PR. Please ping me if you need a hand with this. Thanks!

@shergin
Copy link
Contributor

shergin commented Jun 6, 2017

@alvaromb I would love to see passed tests. 😄

@facebook-github-bot facebook-github-bot added GH Review: accepted Import Started This pull request has been imported. This does not imply the PR has been approved. and removed GH Review: review-needed labels Jul 20, 2017
@facebook-github-bot
Copy link
Contributor

@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification.

@facebook-github-bot facebook-github-bot added Import Failed and removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Jul 20, 2017
@alvaromb
Copy link
Contributor Author

Hi @shergin!

This PR got merged? If not, what can I help you with to merge it?

@facebook-github-bot
Copy link
Contributor

@alvaromb I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project.

@carlost
Copy link

carlost commented Oct 5, 2017

@alvaromb I got bitten by this issue an burned some time trying to track it down. a local change to how jest mocks out the ScrollView works but it would have been nice to have that time back :)

looks like your PR fails in CI and it now has a merge conflict with master.

CI

i can't see the details for the failure in CircleCI ... but the build was from a few months ago so it may have been flushed. The details for the travis-ci build failure are still available: https://travis-ci.org/facebook/react-native/jobs/255491208#L3150

The failure is:

node_modules/react-native/Libraries/Components/ScrollView/__mocks__/ScrollViewMock.js:23
23: const ScrollViewComponent = jest.genMockFromModule('ScrollView');
                                ^^^^ identifier `jest`. Could not resolve name

This occurs during the flow check portion of the iOS build. Based on the date of the build i think this is the line number in the build script where the failure occurs:

if (exec(`${ROOT}/node_modules/.bin/flow check`).code) {

So the rub is, your source file to create the mock specifies the use of flow, but flow doesn't recognize the jest identifier.

Two options (and I am not sure which is the react-native preference because there are examples of both in the source):

Merge Conflict

Looks like master was updated to support a flow v0.53. I don't think that this impacts your PR, you just need to rebase.

Let me know if you want to see this through or if you want to close out this PR and have me open up a replacement.

@alvaromb
Copy link
Contributor Author

alvaromb commented Oct 6, 2017

Just merged against master, tests fails due to other issues though.

@alvaromb
Copy link
Contributor Author

alvaromb commented Oct 6, 2017

Honestly, I don't know how I should proceed from here, should I merge against another branch? @shergin @carlost

@shergin
Copy link
Contributor

shergin commented Oct 6, 2017

¯_(ツ)_/¯
Previous landing was unsuccessful because fb internal tool detected that this diff got new version on GH.

@alvaromb
Copy link
Contributor Author

alvaromb commented Oct 9, 2017

Should I open a new PR @shergin @satya164 ?

@facebook-github-bot
Copy link
Contributor

@alvaromb I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project.

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Nov 28, 2017
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@shergin is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

bowerman0 pushed a commit to bowerman0/react-native that referenced this pull request Dec 5, 2017
Summary:
Solves facebook#13034

Now the `ScrollView` mock has all the methods available.

React Native tests pass.

To test this specific part of the code,

```sh
$ react-native init Test
$ cd Test/
$ yarn add react-navigation
```

Then, add a simple project that uses `react-navigation`:

```js
import React from 'react';
import { Text } from 'react-native';
import { StackNavigator } from 'react-navigation';

class HomeScreen extends React.Component {
  static navigationOptions = {
    title: 'Welcome',
  };
  render() {
    return <Text>Hello, Navigation!</Text>;
  }
}

const SimpleApp = StackNavigator({
  Home: { screen: HomeScreen },
});

export default SimpleApp
```

Run the default render tests:

```js
$ npm run test
```
Closes facebook#13048

Differential Revision: D4746028

Pulled By: shergin

fbshipit-source-id: cb1791978d15be7f5d14b7b22979388066ad6caa
bowerman0 pushed a commit to bowerman0/react-native that referenced this pull request Dec 5, 2017
Summary:
Solves facebook#13034

Now the `ScrollView` mock has all the methods available.

React Native tests pass.

To test this specific part of the code,

```sh
$ react-native init Test
$ cd Test/
$ yarn add react-navigation
```

Then, add a simple project that uses `react-navigation`:

```js
import React from 'react';
import { Text } from 'react-native';
import { StackNavigator } from 'react-navigation';

class HomeScreen extends React.Component {
  static navigationOptions = {
    title: 'Welcome',
  };
  render() {
    return <Text>Hello, Navigation!</Text>;
  }
}

const SimpleApp = StackNavigator({
  Home: { screen: HomeScreen },
});

export default SimpleApp
```

Run the default render tests:

```js
$ npm run test
```
Closes facebook#13048

Differential Revision: D4746028

Pulled By: shergin

fbshipit-source-id: cb1791978d15be7f5d14b7b22979388066ad6caa
@hramos hramos added the Merged This PR has been merged. label Mar 8, 2019
@react-native-bot react-native-bot removed the Import Started This pull request has been imported. This does not imply the PR has been approved. label Mar 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. JavaScript Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants