反应本机版本:0.58.5
我尝试用笑话来连接本机反应。
我需要在项目中配置配置文件以实现自动化和恢复。
我对 package.json
的依赖{
"dependencies": {
"@brazilian-utils/format-cpf": "^0.1.8",
"axios": "^0.18.0",
"cpf": "^2.0.1",
"email-validator": "^2.0.4",
"lodash.debounce": "^4.0.8",
"native-base": "^2.12.1",
"react": "16.6.3",
"react-native": "0.58.5",
"react-native-awesome-alerts": "^1.2.0",
"react-native-banner-carousel": "^1.0.3",
"react-native-camera": "^2.7.0",
"react-native-confirmation-code-input": "^1.0.4",
"react-native-credit-card-input": "^0.4.1",
"react-native-datepicker": "^1.7.2",
"react-native-dropdownalert": "^3.9.2",
"react-native-elements": "^1.1.0",
"react-native-gesture-handler": "^1.1.0",
"react-native-global-font": "^1.0.2",
"react-native-htmlview": "^0.13.0",
"react-native-icon-badge": "^1.1.3",
"react-native-image-zoom-viewer": "^2.2.26",
"react-native-maps": "^0.23.0",
"react-native-numeric-input": "^1.6.5",
"react-native-onesignal": "^3.2.12",
"react-native-paper": "^2.15.2",
"react-native-picker-select": "^6.1.0",
"react-native-progress": "^3.6.0",
"react-native-pull-to-refresh": "^2.1.3",
"react-native-reanimated": "^1.0.0",
"react-native-search-header": "^0.3.2",
"react-native-share": "^1.1.3",
"react-native-spinner-button": "^1.0.3",
"react-native-swipeable": "^0.6.0",
"react-native-tab-view": "^2.1.0",
"react-native-timeline-listview": "^0.2.3",
"react-native-vector-icons": "^6.3.0",
"react-navigation": "^3.3.2",
"react-navigation-transitions": "^1.0.10",
"react-redux": "^6.0.1",
"reactotron-react-native": "^1.3.4",
"recyclerlistview": "^1.3.4",
"redux": "^4.0.1"
},
"devDependencies": {
"babel-core": "7.0.0-bridge.0",
"babel-jest": "24.1.0",
"jest": "24.1.0",
"metro-react-native-babel-preset": "0.52.0",
"react-native-debugger-open": "^0.3.19",
"react-test-renderer": "16.6.3"
},
"jest": {
"preset": "react-native"
},
"rnpm": {
"assets": [
"./resources/fonts"
]
}
}
我有一个初始的测试代码:
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', () => {
const tree = renderer.create(
<App />
).toJSON();
expect(tree).toMatchSnapshot();
});
运行:npm test
错误:
/Users/macti/Documents/XXX/node_modules/native-base-shoutem-theme/index.js:1
({{“ Object。”:function(module,exports,require,__ dirname,__ filename,global,jest){import 来自“ ./src/connectStyle”的connectStyle; ^^^^^^^^^^^^^
SyntaxError: Unexpected identifier at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:440:17) at Object.<anonymous> (node_modules/native-base/src/index.js:1:1)
答案 0 :(得分:0)
上周我有同样的问题可以解决我的问题
"jest": {
"preset": "react-native",
"transformIgnorePatterns": [
"node_modules/(?!react-native|native-base-shoutem-theme|@shoutem/animation|@shoutem/ui|tcomb-form-native)"
],
"setupFiles": [
"./test/setup.js"
]
}