我能够在本地运行测试,但是在travis上出现以下错误:
SyntaxError: Unexpected token ...
at ScriptTransformer._getTransformer (node_modules/jest-runtime/build/script_transformer.js:231:19)
我有一个本机反应项目,最近我升级到Babel 7,在玩笑方面有很多问题。因此,我不得不将以下内容添加到我的package.json中。
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
},
我的babel.rc文件如下:
{
"presets": ["react-native", "@babel/preset-env"]
}
我的package.json如下:
"dependencies": {
"babel-preset-react-native": "^5.0.1",
"react": "16.4.1",
"react-native": "0.56.0",
"react-native-device-info": "^0.12.1",
"react-native-google-analytics-bridge": "^5.8.0",
"react-native-i18n": "^2.0.9",
"react-native-linear-gradient": "^2.4.0",
"react-native-simple-gauge": "^0.1.10",
"react-navigation": "~2.1.0",
"react-redux": "^5.0.6",
"redux": "^4.0.0",
"redux-persist": "^4.10.1",
"redux-thunk": "^2.2.0",
},
"devDependencies": {
"@babel/core": "7.0.0-beta.47",
"@babel/preset-env": "^7.0.0-beta.47",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.4.2",
"enzyme": "^3.1.1",
"enzyme-adapter-react-16": "^1.0.4",
"eslint": "^4.10.0",
"fetch-mock": "^5.13.0",
"flow-bin": "^0.61.0",
"jest": "^23.2.0",
"react-addons-test-utils": "16.0.0-alpha.3",
"react-dom": "^16.0.0",
"react-native-webpack-server": "^0.9.3",
"react-test-renderer": "16.4.1",
"redux-mock-store": "^1.3.0",
"regenerator-runtime": "^0.12.0"
},
"jest": {
"preset": "react-native",
"setupFiles": [
"./jest/setup.js"
],
"verbose": true,
"setupTestFrameworkScriptFile": "./jest/afterTestFramework",
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|react-navigation|react-clone-referenced-element)"
],
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*(test|spec))\\.jsx?$"
}
}