React native 尝试运行react本机组件的测试用例并获得';TypeError:无法读取属性';默认值';未定义的';

React native 尝试运行react本机组件的测试用例并获得';TypeError:无法读取属性';默认值';未定义的';,react-native,jestjs,React Native,Jestjs,我已经编写了一个jest测试来测试react本机组件,我得到了以下错误: Test suite failed to run TypeError: Cannot read property 'default' of undefined at Object.<anonymous> (node_modules/regenerator-runtime/runtime.js:584:62) at Object.<anonymous> (node_

我已经编写了一个jest测试来测试react本机组件,我得到了以下错误:

Test suite failed to run

    TypeError: Cannot read property 'default' of undefined

      at Object.<anonymous> (node_modules/regenerator-runtime/runtime.js:584:62)
      at Object.<anonymous> (node_modules/react-native/jest/setup.js:444:34)
最后,我前面提到的密码组件如下所示:

import React, { Component } from 'react';
import auth from '@react-native-firebase/auth';
import { Text, ScrollView } from 'react-native'
import { Button, Provider as PaperProvider, TextInput } from 'react-native-paper';
import { styles } from '../styles/styleForgotpassword'


class Forgotpassword extends Component {

    constructor () {
        super();
        this.state = {
            email: '',
            error: '',
            success: '',
        }
    }

    onPress = () => {
        if (this.state.email === '') {
            this.setState({ error :'Must enter a valid email'});
            return;
        }
        
        auth().sendPasswordResetEmail(this.state.email).then(() => {
            this.setState({success : "Go to your email and reset your password.", error : ''});
        }).catch( error => {
            if (error.code === 'auth/user-not-found') {
                this.setState({error: "The user does not exist. Please enter the email you signed up with.", success: ''});
            } else if (error.code === 'auth/invalid-email'){
                this.setState({error: "The email format is not correct. The email should look like example@domain.com", success: ''});
            }
        });
    }

    render() {
        return(
            <PaperProvider>
            <ScrollView style={styles.container}>
            <Text style={styles.success}>{this.state.success}</Text>
            <Text style={styles.error}>{this.state.error}</Text>
            <TextInput
                label='Enter your Email address'
                mode='outlined'
                multiline
                blurOnSubmit
                autoCapitalize="none"
                onChangeText={email => this.setState({ email })}
                value={this.state.email}
            />
            <Button style={styles.button} onPress={() => this.onPress()}>
                <Text style={styles.buttontext}>
                    Send
                </Text>
            </Button>
                    <Button style={styles.button} onPress={() => this.props.navigation.navigate('Signin')}>
                        <Text style={styles.buttontext}>
                            Sign In
                        </Text>
                    </Button>
            </ScrollView>
          </PaperProvider>
        )
    }

}

export default Forgotpassword;

import React,{Component}来自'React';
从'@react native firebase/auth'导入身份验证;
从“react native”导入{Text,ScrollView}
从“react native paper”导入{按钮,提供程序作为PaperProvider,TextInput};
从“../styles/styleForgotpassword”导入{styles}
类Forgotpassword扩展组件{
构造函数(){
超级();
此.state={
电子邮件:“”,
错误:“”,
成功:'',
}
}
onPress=()=>{
如果(this.state.email===''){
this.setState({错误:'必须输入有效的电子邮件'});
返回;
}
auth().sendPasswordResetEmail(this.state.email)。然后(()=>{
this.setState({success:“转到您的电子邮件并重置密码。”,错误:'});
}).catch(错误=>{
如果(error.code==='auth/user not found'){
this.setState({错误:“用户不存在。请输入您注册的电子邮件。”,成功:'});
}else if(error.code==='auth/invalid email'){
this.setState({error:“电子邮件格式不正确。电子邮件应如下所示example@domain.com,成功:'});
}
});
}
render(){
返回(
{this.state.success}
{this.state.error}
this.setState({email})}
值={this.state.email}
/>
this.onPress()}>
发送
this.props.navigation.navigate('sign')}>
登录
)
}
}
导出默认放弃密码;

 "jest": {
        "preset": "react-native",
        "transform": {
            "^.+\\.[jt]sx?$": "babel-jest"
        },
        "transformIgnorePatterns": [
            "node_modules/?!(react-native|react-navigation)"
            
        ],
        "automock" : true,
        "verbose" : true
    },

import React, { Component } from 'react';
import auth from '@react-native-firebase/auth';
import { Text, ScrollView } from 'react-native'
import { Button, Provider as PaperProvider, TextInput } from 'react-native-paper';
import { styles } from '../styles/styleForgotpassword'


class Forgotpassword extends Component {

    constructor () {
        super();
        this.state = {
            email: '',
            error: '',
            success: '',
        }
    }

    onPress = () => {
        if (this.state.email === '') {
            this.setState({ error :'Must enter a valid email'});
            return;
        }
        
        auth().sendPasswordResetEmail(this.state.email).then(() => {
            this.setState({success : "Go to your email and reset your password.", error : ''});
        }).catch( error => {
            if (error.code === 'auth/user-not-found') {
                this.setState({error: "The user does not exist. Please enter the email you signed up with.", success: ''});
            } else if (error.code === 'auth/invalid-email'){
                this.setState({error: "The email format is not correct. The email should look like example@domain.com", success: ''});
            }
        });
    }

    render() {
        return(
            <PaperProvider>
            <ScrollView style={styles.container}>
            <Text style={styles.success}>{this.state.success}</Text>
            <Text style={styles.error}>{this.state.error}</Text>
            <TextInput
                label='Enter your Email address'
                mode='outlined'
                multiline
                blurOnSubmit
                autoCapitalize="none"
                onChangeText={email => this.setState({ email })}
                value={this.state.email}
            />
            <Button style={styles.button} onPress={() => this.onPress()}>
                <Text style={styles.buttontext}>
                    Send
                </Text>
            </Button>
                    <Button style={styles.button} onPress={() => this.props.navigation.navigate('Signin')}>
                        <Text style={styles.buttontext}>
                            Sign In
                        </Text>
                    </Button>
            </ScrollView>
          </PaperProvider>
        )
    }

}

export default Forgotpassword;