Tôi có kiểm tra jest sau:Không thể tìm thấy mô-đun từ 'phản ứng bản địa-implementation.js'
import React from 'react';
import IndexSign from '../IndexSign';
import renderer from 'react-test-renderer';
it('renders correctly',() => {
const tree = renderer.create(
<IndexSign index={1}/>
).toJSON();
expect(tree).toMatchSnapshot();
});
Các IndexSign
thành phần mà tôi đang kêu gọi các cuộc gọi StyleSheet
thành phần này:
import {StyleSheet} from 'react-native';
export default StyleSheet.create({
//some styles
});
Đối thử nghiệm, tôi đang sử dụng Gulp:
gulp.task('tests',() => {
process.env.NODE_ENV = 'test';
return gulp.src('src').pipe(jest({
}));
});
Vấn đề là khi tôi chạy chương trình này st, tôi nhận được:
● Test suite failed to run
Cannot find module 'StyleSheet' from 'react-native-implementation.js'
at Resolver.resolveModule (../node_modules/jest-resolve/build/index.js:142:17)
at Object.StyleSheet (../node_modules/react-native/Libraries/react-native/react-native-implementation.js:98:25)
at Object.<anonymous> (styles/Styles.js:5:13)
Bất kỳ ý tưởng nào tại sao điều này đang xảy ra?
Tại sao tìm kiếm StyleSheet
trong react-native-implementation.js
thay vì react-native
, tôi đã nhập?
Và tại sao nó không tìm thấy StyleSheet
?
Bạn đã tìm thấy giải pháp chưa? Stumbled khi điều này là tốt – Zephir77167