У меня возникла проблема с Jest при тестировании компонента приложения React Native. Несколько других компонентов уже проходят тест в соответствии с ожиданиями с той же конфигурацией шутки, но этот выдает странную ошибку, поэтому вам нужна помощь.
import React, { Component, Fragment } from "react";
import { func } from "prop-types";
import { View, Text } from "react-native";
import { TextInput, Button } from "react-native-paper";
import { STYLE_CONSTANTS } from "../../config/styles";
import styles from "./styles";
import { loginScreenText } from "./helpers";
class SignIn extends Component {
state = {
isLoading: false
};
render() {
const { isLoading } = this.state;
const { showAppAction } = this.props;
return (
<Fragment>
<View style = {styles.signInContainer}>
<Text style = {styles.oAuthHeading}>
{loginScreenText.oAuthHeading}
</Text>
<View style = {styles.spacer} />
<Button
icon = {require("../../assets/images/facebook.png")}
mode = "contained"
loading = {isLoading}
color = {STYLE_CONSTANTS.COLORS.FACEBOOK}
style = {styles.facebookButton}
onPress = {() => showAppAction()}
>
{loginScreenText.facebookButton}
</Button>
<View style = {styles.spacer} />
<Button
icon = {require("../../assets/images/google.png")}
mode = "contained"
loading = {isLoading}
color = {STYLE_CONSTANTS.COLORS.GOOGLE}
style = {styles.googleButton}
onPress = {() => showAppAction()}
>
{loginScreenText.googleButton}
</Button>
</View>
</Fragment>
);
}
}
SignIn.propTypes = {
showAppAction: func
};
export default SignIn;
import "react-native";
import React from "react";
import ShallowRenderer from "react-test-renderer/shallow";
import SignIn from "../containers/SignIn";
test('renders SignIn component correctly', () => {
const renderer = new ShallowRenderer();
renderer.render(<SignIn showAppAction = {jest.fn()} />);
const wrapper = renderer.getRenderOutput();
expect(wrapper).toMatchSnapshot();
});
"jest": {
"preset": "react-native",
"collectCoverage": true,
"coverageDirectory": "__coverage__",
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
},
"transformIgnorePatterns": [
"node_modules/(?!react-native|native-base|react-navigation|react-native-fabric|react-native-paper)"
]
},
Наконец скрин ошибки



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


Мне удалось решить эту проблему, следя за обсуждением здесь