admin管理员组文章数量:1356215
After upgrading my project from Expo45 to Expo48, I encounter this error when running the test:
TypeError: Cannot read properties of undefined (reading 'exists')
at exists (node_modules/expo-asset/src/PlatformUtils.ts:65:17)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
The unit test itself is quite simple:
it('Should be able rendered properly', () => {
render(
<UserContext.Provider
value={[initialState, jest.fn()]}
>
<UpdatePasswordScreen />
</UserContext.Provider>,
);
});
The UpdatePasswordScreen ponent is like this:
<View style={styles.container}>
<Spinner
visible={showSpinner}
textContent={'Loading...'}
textStyle={{
color: '#FFFFFF',
}}
/>
<CustomInput
titleStyle={{
size: 13,
}}
titleContainerStyle={{
marginBottom: 10,
}}
containerStyle={{
marginBottom: 8,
}}
placeholder="Enter Password"
title="Old password"
value={oldPassword}
secureTextEntry={!showOldPassword}
onRenderLeftIcon={() => (
<Icon
name={showOldPassword ? 'eye' : 'eye-off'}
type="feather"
size={20}
color="#AFB4B9"
onPress={() => setShowOldPassword(!showOldPassword)}
/>
)}
onChangeText={setOldPassword}
/>
<View style={styles.confirmButton}>
<IconButton
text="Reset Password"
buttonStyle={{
height: 52,
width: 200,
}}
onPress={updatePassword}
disabled={!oldPassword || !newPassword
|| !confirmNewPassword || showPasswordErrorMessage()
|| newPassword !== confirmNewPassword
|| oldPasswordUnchanged
}
/>
</View>
</View>
I just want to render the ponent but it doesn't work. The unit test run well under Expo45.
Any suggestions will be appreciated!
How to solve this problem?
After upgrading my project from Expo45 to Expo48, I encounter this error when running the test:
TypeError: Cannot read properties of undefined (reading 'exists')
at exists (node_modules/expo-asset/src/PlatformUtils.ts:65:17)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
The unit test itself is quite simple:
it('Should be able rendered properly', () => {
render(
<UserContext.Provider
value={[initialState, jest.fn()]}
>
<UpdatePasswordScreen />
</UserContext.Provider>,
);
});
The UpdatePasswordScreen ponent is like this:
<View style={styles.container}>
<Spinner
visible={showSpinner}
textContent={'Loading...'}
textStyle={{
color: '#FFFFFF',
}}
/>
<CustomInput
titleStyle={{
size: 13,
}}
titleContainerStyle={{
marginBottom: 10,
}}
containerStyle={{
marginBottom: 8,
}}
placeholder="Enter Password"
title="Old password"
value={oldPassword}
secureTextEntry={!showOldPassword}
onRenderLeftIcon={() => (
<Icon
name={showOldPassword ? 'eye' : 'eye-off'}
type="feather"
size={20}
color="#AFB4B9"
onPress={() => setShowOldPassword(!showOldPassword)}
/>
)}
onChangeText={setOldPassword}
/>
<View style={styles.confirmButton}>
<IconButton
text="Reset Password"
buttonStyle={{
height: 52,
width: 200,
}}
onPress={updatePassword}
disabled={!oldPassword || !newPassword
|| !confirmNewPassword || showPasswordErrorMessage()
|| newPassword !== confirmNewPassword
|| oldPasswordUnchanged
}
/>
</View>
</View>
I just want to render the ponent but it doesn't work. The unit test run well under Expo45.
Any suggestions will be appreciated!
How to solve this problem?
Share Improve this question edited Apr 4, 2023 at 23:33 Zachary Zhao asked Apr 4, 2023 at 23:11 Zachary ZhaoZachary Zhao 413 bronze badges1 Answer
Reset to default 13I fixed this error by adding these lines to my jest setup file :
jest.mock("expo-font");
jest.mock("expo-asset");
本文标签:
版权声明:本文标题:javascript - After upgrading to Expo48 Meeting this error: TypeError: Cannot read properties of undefined (reading 'exis 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744062461a2584377.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论