Реагировать на использование собственных шуток TypeError: Невозможно прочитать свойство propTypes из неопределенного - PullRequest
2 голосов
/ 04 октября 2019

Я пытаюсь интегрировать свое приложение с шуткой. Когда я запускаю yarn test, я получаю следующую ошибку, и даже игнорирование преобразования кажется неэффективным:

╰─± yarn test
yarn run v1.17.3
$ jest
 FAIL  __tests__/App-test.js
  ● Test suite failed to run

    TypeError: Cannot read property 'propTypes' of undefined

      at propTypes (node_modules/react-native/Libraries/Animated/src/createAnimatedComponent.js:178:31)
      at Object.oldCreate [as createAnimatedComponent] (node_modules/react-native/jest/setup.js:143:23)
      at Object.createAnimatedComponent (node_modules/react-navigation-stack/lib/commonjs/views/BorderlessButton.js:1:1222)
      at Object.require (node_modules/react-navigation-stack/lib/commonjs/views/TouchableItem.js:1:1053)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        8.653s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Вот мой jest config в package.json:

  "jest": {
    "preset": "react-native",
    "transformIgnorePatterns": [
      "node_modules/(?!((jest-)?react-native|react-clone-referenced-element|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|sentry-expo|native-base))"
    ]
  }

И здесьмой основной тестовый файл:

/**
 * @format
 */

import "react-native";
import React from "react";
import App from "../src/App";

// Note: test renderer must be required after react-native.
import renderer from "react-test-renderer";

it("renders correctly", () => {
    renderer.create(<App />);
});

И содержимое App.js:

import React, {Component} from "react";
import {Provider as ThemeProvider} from "react-native-paper";
import {Provider as ReduxProvider} from "react-redux";
import {PersistGate} from "redux-persist/integration/react";
import Pushe from "react-native-pushe";
import {ReduxNetworkProvider} from "react-native-offline";

import {configureI18n} from "i18n";
import {store, persistor} from "store";
import Navigator from "navigator";
import NavigationService from "navigator/NavigationService";
import theme from "theme";
import Feedback from "containers/Feedback";

export default class App extends Component {
    constructor(props) {
        super(props);
        configureI18n();
        Pushe.initialize(true);
    }

    componentDidMount() {
        if (global.HermesInternal != null) {
            console.log("Herms enabled!");
        }
    }

    setNavigatorRef = (ref) => NavigationService.setTopLevelNavigator(ref);

    render() {
        return (
            <ReduxProvider store={store}>
                <ReduxNetworkProvider pingInterval={30000} pingOnlyIfOffline={true}>
                    <PersistGate loading={null} persistor={persistor}>
                        <ThemeProvider theme={theme}>
                            <>
                                <Navigator ref={this.setNavigatorRef} uriPrefix="test://" />
                                <Feedback />
                            </>
                        </ThemeProvider>
                    </PersistGate>
                </ReduxNetworkProvider>
            </ReduxProvider>
        );
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...