Downshift: Fix react native tests

Created on 8 Oct 2018  ·  6Comments  ·  Source: downshift-js/downshift

They're currently disabled. I'm not sure what's wrong with them.

I don't have time to work on this and I don't use react native. So we'll need contributions here.

help wanted needs investigation

All 6 comments

Sorry I missed when this happened before! 🤔

Is there a point when CI failed? I'll repro this locally, but discussing over a build failure might be more helpful.

I'd say this is due to React Native 0.57 changing the default Babel preset, from babel-preset-react-native to metro-react-native-babel-preset: https://github.com/react-native-community/react-native-releases/issues/34#issuecomment-407006185

I'll pick this one up real quick and see what I can find.

Here's a better link to the changes that need to happen: https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md#updating-to-this-version

Hmmm, upgrading only the Babel preset doesn't seem to address all the issues, as I still get the following error after running yarn remove babel-preset-react-native && yarn add --dev metro-react-native-babel-preset@\^0.45.0 && yarn run jest --projects other/misc-tests other/react-native

  ● Console

    console.error node_modules/react-test-renderer/cjs/react-test-renderer.development.js:6884
      The above error occurred in the <mockConstructor> component:
          in mockConstructor (at onChange-tests.js:19)
          in View (created by Component)
          in Component (at onChange-tests.js:9)
          in RootView (at onChange-tests.js:18)
          in Downshift (at onChange-tests.js:16)

      Consider adding an error boundary to your tree to customize error handling behavior.
      Visit https://fb.me/react-error-boundaries to learn more about error boundaries.

  ● calls onChange when TextInput changes values

    Cannot find module 'schedule/tracking' from 'ReactNativeRenderer-dev.js'

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:221:17)
      at node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:29:20
      at Object.<anonymous> (node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:16199:5)

Aaaaaand one more bit of sleuthing to discover some more context here: https://github.com/facebook/react-native/issues/21150#issuecomment-427768751

I ran yarn add --dev [email protected] followed by yarn run jest --projects other/react-native and got the following:

❯ yarn run jest --projects other/react-native
yarn run v1.10.1
$ /Users/eliperkins/src/downshift/node_modules/.bin/jest --projects other/react-native
 PASS  other/react-native/__tests__/onBlur-tests.js

 RUNS  other/react-native/__tests__/onChange-tests.js
/Users/eliperkins/src/downshift/dist/downshift.native.cjs.js:1035
      var downshiftButtonIsActive = _this4.props.environment.document.activeElement.dataset.toggle && _this4._rootNode && _this4._rootNode.contains(_this4.props.environment.document.activeElement);
                                                                      ^

TypeError: Cannot read property 'activeElement' of undefined
    at Timeout._onTimeout (/Users/eliperkins/src/downshift/dist/downshift.native.cjs.js:1035:71)
    at ontimeout (timers.js:427:11)
    at tryOnTimeout (timers.js:289:5)
    at listOnTimeout (timers.js:252:5)
    at Timer.processTimers (timers.js:212:10)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I'm out of time to look at this further tonight, but I'd say we've got some pretty hairy version mismatches to unwind here, along with a wee bit of platform mismatch in usage of things like document for certain platforms.

If someone wants to pick this up before me, feel free! Otherwise, I can pick this up at my next free moment.

Was this page helpful?
0 / 5 - 0 ratings