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

Tests failing on a newly created app #15810

Closed
cschroeter opened this issue Sep 5, 2017 · 10 comments
Closed

Tests failing on a newly created app #15810

cschroeter opened this issue Sep 5, 2017 · 10 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@cschroeter
Copy link

Is this a bug report?

yes

Have you read the Contributing Guidelines?

yes

Environment

react-native-cli: 2.0.1
react-native: 0.48.1
node: v8.4.0
yarn: 0.27.5

  • Target Platform:
    iOs, Android
  • Development Operating System:
    macOs Sierra 10.12.6

Steps to Reproduce

  1. react-native init testapp
  2. cd testapp
  3. yarn test

Expected Behavior

Initially created tests should pass.

Actual Behavior

yarn test
yarn test v0.27.5
$ jest
 FAIL  __tests__/index.android.js
  ● Test suite failed to run

    TypeError: Cannot read property 'BLOB_URI_SCHEME' of undefined

      at Object.<anonymous> (node_modules/react-native/Libraries/Blob/URL.js:21:21)
      at node_modules/react-native/Libraries/Core/InitializeCore.js:174:40
      at getValue (node_modules/react-native/Libraries/Utilities/defineLazyObjectProperty.js:44:10)
      at ContextifyScript.Script.runInContext (vm.js:53:29)

 FAIL  __tests__/index.ios.js
  ● Test suite failed to run

    TypeError: Cannot read property 'BLOB_URI_SCHEME' of undefined

      at Object.<anonymous> (node_modules/react-native/Libraries/Blob/URL.js:21:21)
      at node_modules/react-native/Libraries/Core/InitializeCore.js:174:40
      at getValue (node_modules/react-native/Libraries/Utilities/defineLazyObjectProperty.js:44:10)
      at ContextifyScript.Script.runInContext (vm.js:53:29)

Test Suites: 2 failed, 2 total
Tests:       0 total
Snapshots:   0 total
Time:        0.95s
Ran all test suites.
error Command failed with exit code 1.
@shaundon
Copy link

shaundon commented Sep 5, 2017

I dropped back to version 0.47.x and this no longer happens - have you tried that?

@cschroeter
Copy link
Author

cschroeter commented Sep 5, 2017

@shaundon I just have migrated to the latest version. Tests passed on 0.47.1

@ghost
Copy link

ghost commented Sep 6, 2017

Also this issue reproducible on node 8.4.0, but all works fine with node 7.4.0. You can use it how temporary workaround

@sir-gon
Copy link

sir-gon commented Sep 6, 2017

I have the same tool versions in my stack.
I can confirm the issue :/

@timwangdev
Copy link
Contributor

I created PR in #15843 to fix this issue.

alvinthen added a commit to alvinthen/react-native-starter-pack that referenced this issue Sep 7, 2017
facebook-github-bot pushed a commit that referenced this issue Sep 7, 2017
Summary:
React Native v0.48.0 shipped `WebSocketModule` support with `BlobModule` as dependency. But `BlobModule` is not mocked in jest which will cause render tests failed.

Reference implantation: [BlobModule.java](https://github.com/facebook/react-native/blob/ed903099b42259958d8a6eb3af1a6460c1bc8b2c/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.java)

Related PR: #11417
Related issue: #15810

Passed CI tests.
Need render a component in jest with WebSocketModule as dependency.
Closes #15843

Differential Revision: D5783263

Pulled By: shergin

fbshipit-source-id: 2386692f4a644796da2fd66b3135da9f5911663e
rquigley pushed a commit to rquigley/react-native that referenced this issue Sep 14, 2017
Summary:
React Native v0.48.0 shipped `WebSocketModule` support with `BlobModule` as dependency. But `BlobModule` is not mocked in jest which will cause render tests failed.

Reference implantation: [BlobModule.java](https://github.com/facebook/react-native/blob/ed903099b42259958d8a6eb3af1a6460c1bc8b2c/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.java)

Related PR: facebook#11417
Related issue: facebook#15810

Passed CI tests.
Need render a component in jest with WebSocketModule as dependency.
Closes facebook#15843

Differential Revision: D5783263

Pulled By: shergin

fbshipit-source-id: 2386692f4a644796da2fd66b3135da9f5911663e
@richardgirges
Copy link

richardgirges commented Sep 15, 2017

Thanks to @timwangdev's PR, here are some temp workarounds that don't involve downgrading Node, until a release is cut with @timwangdev's fix.

WORKAROUND 1:
Overwrite ./node_modules/react-native/jest/setup.js with this: https://raw.githubusercontent.com/facebook/react-native/master/jest/setup.js

WORKAROUND 2:
WARNING: Risky! I didn't actually test this.

Install RN #master git branch:

"react-native": "git://github.com/facebook/react-native#master"

@timwangdev
Copy link
Contributor

Another workaround does not involve change current RN files (I'm using) is:

Add https://github.com/facebook/react-native/blob/master/jest/setup.js#L112-L307 to your own project's jest-setup.js. This one will actually rewrite the mock for whole NativeModules.

You could remove those lines after the fix releases.

franky47 pushed a commit to franky47/stravels that referenced this issue Sep 18, 2017
Requires to patch tests/setup.js, see facebook/react-native#15810
ide pushed a commit to expo/react-native that referenced this issue Sep 19, 2017
Summary:
React Native v0.48.0 shipped `WebSocketModule` support with `BlobModule` as dependency. But `BlobModule` is not mocked in jest which will cause render tests failed.

Reference implantation: [BlobModule.java](https://github.com/facebook/react-native/blob/ed903099b42259958d8a6eb3af1a6460c1bc8b2c/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.java)

Related PR: facebook#11417
Related issue: facebook#15810

Passed CI tests.
Need render a component in jest with WebSocketModule as dependency.
Closes facebook#15843

Differential Revision: D5783263

Pulled By: shergin

fbshipit-source-id: 2386692f4a644796da2fd66b3135da9f5911663e
ide pushed a commit that referenced this issue Sep 19, 2017
Summary:
React Native v0.48.0 shipped `WebSocketModule` support with `BlobModule` as dependency. But `BlobModule` is not mocked in jest which will cause render tests failed.

Reference implantation: [BlobModule.java](https://github.com/facebook/react-native/blob/ed903099b42259958d8a6eb3af1a6460c1bc8b2c/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.java)

Related PR: #11417
Related issue: #15810

Passed CI tests.
Need render a component in jest with WebSocketModule as dependency.
Closes #15843

Differential Revision: D5783263

Pulled By: shergin

fbshipit-source-id: 2386692f4a644796da2fd66b3135da9f5911663e
ide pushed a commit that referenced this issue Sep 19, 2017
Summary:
React Native v0.48.0 shipped `WebSocketModule` support with `BlobModule` as dependency. But `BlobModule` is not mocked in jest which will cause render tests failed.

Reference implantation: [BlobModule.java](https://github.com/facebook/react-native/blob/ed903099b42259958d8a6eb3af1a6460c1bc8b2c/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.java)

Related PR: #11417
Related issue: #15810

Passed CI tests.
Need render a component in jest with WebSocketModule as dependency.
Closes #15843

Differential Revision: D5783263

Pulled By: shergin

fbshipit-source-id: 2386692f4a644796da2fd66b3135da9f5911663e
Ashoat added a commit to Ashoat/react-navigation that referenced this issue Sep 25, 2017
Ashoat added a commit to Ashoat/react-navigation that referenced this issue Sep 25, 2017
Ashoat added a commit to Ashoat/react-navigation that referenced this issue Sep 25, 2017
Jest is failing to run in NavigationPlayground because of this issue. This is my attempt to fix it, which unfortunately did not work locally...
Ashoat added a commit to Ashoat/react-navigation that referenced this issue Sep 25, 2017
@Ashoat
Copy link
Contributor

Ashoat commented Sep 25, 2017

For anybody still experiencing this issue, note that it is fixed in 0.48.4. It can be closed now.

matthamil pushed a commit to react-navigation/react-navigation that referenced this issue Sep 25, 2017
* Fix .flowconfig to stop ignoring modules and properly include React Native libraries

Currently, there are numerous ignored libraries that are hiding type errors. Actually, they're causing type errors too. This sort of thing only patches over actual problems, so we have to revert them to get a config we can build upon.

* Update react-native/flow-bin dependencies

We want to have Flow types working with the latest packages.

* Update flow-typed libraries (auto-generated)

* Fix typing of navigation prop used by withNavigation HOC

The current typing is clearly a typo, as it is circular. `NavigationScreenProp` should be used to type the navigation prop

* Fix typing of easing function

What's funny is that I fixed this before in d71ed75. @skevy reintroduced the mistyped function in 9436d03, which didn't trigger any Flow errors because .flowconfig was ignoring the entire react-native package

* Correct typing of View and Text style prop

The current code thinks it can import these, but this isn't true, and was being hidden because the .flowconfig ignored the whole react-native package. There's no easy to type Text and View at the current moment, as far as I can tell. Importing the highly generic `StyleObj` seems like the best bet, and is what I have being using in my projects.

* Import NavigationScreenComponent using full path

* Updating yarn.lock files

* Get rid of library overrides in flow-typed/react-native.js and flow/react-navigation.js

* Add @flow to src/react-navigation.js and make last three params to createNavigator optional

* Make screenProps and navigationOptions optional in NavigationNavigatorProps

* yarn run format

* Readd react-navigation/node_modules ignore to NavigationPlayground's .flowconfig

Realized this line I removed in the first commit is necessary when using npm link/yarn link, which is what the CircleCI build does

* Make all DrawerViewConfig's params optional

Some of these params are marked as optional because they have defaults. However, the only place `DrawerViewConfig` is used is as the input the function that then applies the defaults

* Make all props in NavigationNavigatorProps optional

`NavigationNavigatorProps` is used to type the props of the component that is output by the `StackNavigator`, `TabNavigator`, etc. component factories. This component does not need to have any props specified.

* Make second param to `DrawerNavigator` factory optional

`DrawerNavigator`, just like `TabNavigator` and `StackNavigator`, can be called with just a single argument (ie. omitting the config)

* Upgrade to RN 0.48.4 to address facebook/react-native#15810
@timwangdev
Copy link
Contributor

@facebook-github-bot close

@ide ide closed this as completed Sep 26, 2017
@rsp8055
Copy link

rsp8055 commented Apr 7, 2018

MyDemo@0.0.1 test /home/MyDemo
jest

FAIL tests/App.js
● Test suite failed to run

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string

  at assertPath (path.js:28:11)
  at Object.relative (path.js:1249:5)

FAIL tests/App-test.js
● Test suite failed to run

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string

  at assertPath (path.js:28:11)
  at Object.relative (path.js:1249:5)

Test Suites: 2 failed, 2 total
Tests: 0 total
Snapshots: 0 total
Time: 0.47s
Ran all test suites.
npm ERR! Test failed. See above for more details

tried by various ways but could not found exact solution, even dont know the exact problem.

@facebook facebook locked as resolved and limited conversation to collaborators Sep 26, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Sep 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

9 participants